home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Reference / the cmsp digests ('94-'97) / csmp digest Vol 3 No 130 < prev    next >
Text File  |  1996-01-05  |  106KB  |  3,165 lines

  1. C.S.M.P. Digest             Fri, 05 Jan 96       Volume 3 : Issue 130
  2.  
  3. Today's Topics:
  4.  
  5.         Achieving constant frame rates for a game
  6.         Async I-O, timer routines, on Power PCs - where documented?
  7.         BalloonWriter? Resourcer? or...
  8.         Code Compiling on the fly? [PPC]
  9.         Creating AE "whose" clause (using formTest) from C?
  10.         From FSSpec to DirID
  11.         Getting the Highlight color as set in the Color Control Panel?
  12.         Help patching NewPtr on PPC?
  13.         Is delta copying effective?
  14.         NBP Lookups
  15.         PICT opcode $9a?
  16.         Parameter Block woes
  17.         Pixel manipulation
  18.         Stupid locked file question
  19.         Using Enqueue() and Dequeue() for custom-made queues
  20.         [HELP] New to color palettes...simple question!
  21.  
  22.  
  23.  
  24. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  25. (pottier@clipper.ens.fr).
  26.  
  27. The digest is a collection of article threads from the internet
  28. newsgroups comp.sys.mac.programmer.help, csmp.tools, csmp.misc and
  29. csmp.games. It is designed for people who read news semi-regularly and
  30. want an archive of the discussions.  If you don't know what a
  31. newsgroup is, you probably don't have access to it. Ask your systems
  32. administrator(s) for details. If you don't have access to news, you
  33. may still be able to post messages to the group by using a mail server
  34. like anon.penet.fi (mail help@anon.penet.fi for more information).
  35.  
  36. Each issue of the digest contains one or more sets of articles (called
  37. threads), with each set corresponding to a 'discussion' of a particular
  38. subject.  The articles are not edited; all articles included in this digest
  39. are in their original posted form (as received by our news server at
  40. nef.ens.fr).  Article threads are not added to the digest until the last
  41. article added to the thread is at least two weeks old (this is to ensure that
  42. the thread is dead before adding it to the digest).  Article threads that
  43. consist of only one message are generally not included in the digest.
  44.  
  45. The digest is officially distributed by two means, by email and ftp.
  46.  
  47. If you want to receive the digest by mail, send email to listserv@ens.fr
  48. with no subject and one of the following commands as body:
  49.     help                                Sends you a summary of commands
  50.     subscribe csmp-digest Your Name     Adds you to the mailing list
  51.     signoff csmp-digest                 Removes you from the list
  52. Once you have subscribed, you will automatically receive each new
  53. issue as it is created.
  54.  
  55. The official ftp info is ftp://ftp.dartmouth.edu/pub/csmp-digest.
  56. Questions related to the ftp site should be directed to
  57. scott.silver@dartmouth.edu.
  58.  
  59. -------------------------------------------------------
  60.  
  61. >From joel@phantom.itg.ti.com (Joel Quejada)
  62. Subject: Achieving constant frame rates for a game
  63. Date: 18 Dec 1995 18:05:20 GMT
  64. Organization: Texas Instruments, Inc.
  65.  
  66. I am writing a game in which I would like a constant frame rate throughout.
  67. I also would like the game to take advantage of faster machines, by making
  68. the sprite movements smaller. The end result should be smoother animation
  69. on faster machines. The game compensates on slower machines by moving the
  70. sprite in larger increments.
  71.  
  72. In the beginning of my game, I run a benchmark that checks to see what
  73. frame rate can be achieved by a system when the maximum number of
  74. sprites are active on the screen. I then peg the frame rate of the game
  75. at this number. This frame rate is also used to pre-calculate a table
  76. that specifies how much to move a sprite assuming this frame rate.
  77.  
  78. This seems to work great. I have a constant frame rate, regardless of
  79. how many sprites are on screen, and sprites move at the "same speed"
  80. regardless of what the frame rate is. My benchmark runs for a couple of
  81. seconds in order to get a good fps reading.
  82.  
  83. My question: is this what is done by other games? Is there an easier
  84. way of determining from the processor type and speed how much fps a
  85. given machine can achieve? 
  86.  
  87.  
  88. Thanks,
  89.  
  90. Joel
  91.  
  92. +++++++++++++++++++++++++++
  93.  
  94. >From phixus@deltanet.com (Chris De Salvo)
  95. Date: Tue, 19 Dec 1995 00:11:23 -0800
  96. Organization: MacPlay
  97.  
  98. In article <4b4ah0$p2l@dsk92.itg.ti.com>, joel@phantom.itg.ti.com (Joel
  99. Quejada) wrote:
  100.  
  101. >My question: is this what is done by other games? Is there an easier
  102. >way of determining from the processor type and speed how much fps a
  103. >given machine can achieve? 
  104.  
  105. One simple method would be to either use the Microseconds() trap or a Time
  106. Manager task to keep track of real-time for you.  Then, you could monitor
  107. your frame-rate against the real-time clock.  Doing this you can then
  108. dynamically adjust your deltas.  When you're going too slow, start moving
  109. more.  When you're going too fast start moving less.
  110.  
  111. This could be useful in cases where you often have big shifts in the
  112. number of things you're moving on screen.
  113.  
  114. L8R
  115. Chris
  116.  
  117. -- 
  118. phixus@deltanet.com         |   Macintosh:  Changing the world,
  119. Chris De Salvo              |        one person at a time!
  120. Professional Mac Geek       |    -----------------------------
  121. for MacPlay, Inc.           |      (I wish they'd hurry up!)
  122.  
  123.            http://www.deltanet.com/users/phixus
  124.  
  125. +++++++++++++++++++++++++++
  126.  
  127. >From Jacques.Menu@hospvd.ch (Jacques MENU)
  128. Date: Wed, 20 Dec 1995 10:30:00 -0800
  129. Organization: OIH - SHC
  130.  
  131. Hi Joel,
  132.  
  133. > My question: is this what is done by other games? Is there an easier
  134. > way of determining from the processor type and speed how much fps a
  135. > given machine can achieve? 
  136.  
  137. I'm no game writer myself, by I had the same problem long time ago, which
  138. I solved in the following way : instances of class TTiming can be sent
  139. messages to let time elapse for a given number of milliseconds or 1e-4
  140. secs.
  141.  
  142. The idea is to sample a large number of iterations on nothing on the
  143. current machine, and to compare the time taken with a reference machine,
  144. which happens to be a good old Mac II.
  145.  
  146. Measures on a datascope show that when asking for a 25 ms delay, I
  147. actually usually get 24, that is, a 4% error.
  148.  
  149. Though this is based essentially on integer arithmetic, I guess you coud
  150. do much the same with floating numbers.
  151.  
  152. Enjoy !
  153.  
  154.  
  155. // •------------------------------------------------------------------------
  156. //  UTiming.h
  157. //  Copyright 1992 by JMI.  All rights reserved.
  158. // •------------------------------------------------------------------------
  159.  
  160. #ifndef __UTiming__
  161. #define __UTiming__
  162.  
  163. #include <stream.h>
  164.  
  165.  
  166. class TTiming
  167.   {
  168. public:
  169.  
  170.                           TTiming (long samplingIterations = 500000);
  171.                             // roughly  0.5 sec  on a Mac II
  172.  
  173.   void                    MilliSecsDelay (long theMilliSecsDelay);
  174.   void                    Ten4SecsDelay (long theTen4SecsDelay);
  175.   
  176.   void                    Report (ostream & theStream);
  177.   
  178.   static void             SampleTiming (ostream & theStream);
  179.  
  180.  
  181. private:
  182.  
  183.   long                    fMilliSecIterations;
  184.                             //  the result of sampling the current machine
  185.  
  186.   float                   fMachineSpeedFactor;
  187.                             //  used to characterize various machine speeds
  188.  
  189.   long                    fSamplingIterations;
  190.   float                   fSamplingDuration;
  191.  
  192.   };  //  TTiming
  193.  
  194.  
  195. #endif __UTiming__
  196.  
  197.  
  198.  
  199.  
  200. // •------------------------------------------------------------------------
  201. //  UTiming.cp
  202. //  Copyright  1992 by JMI. All rights reserved.
  203. // •------------------------------------------------------------------------
  204.  
  205. #pragma segment Timing
  206.  
  207. #ifndef __UTiming__
  208. #include "UTiming.h"
  209. #endif
  210.  
  211.  
  212. //  Idea: determine how many times to iterate over a NOP to attain 1 ms
  213. //  1 tick = 1/60 sec = 16.67 ms = 50/3 ms, hence 1 ms = 3/50 tick
  214.  
  215. const long    kReferenceIterations   = 40000000;
  216.   // roughly 10.0   secs on a Mac II fx
  217.  
  218. const float   kReferenceDuration     = 10.1667;
  219.   // the exact duration of "kReferenceIterations" on a Mac II fx
  220.  
  221. const float   kSpeedFactorCorrection = 0.9525;
  222.   // the value of fMachineSpeedFactor on the reference machine
  223.   // is not exactly equal to 1.0!
  224.  
  225.  
  226. // •------------------------------------------------------------------------
  227.  
  228. TTiming :: TTiming (long samplingIterations)
  229.   {
  230.   long    startTicks, endTicks;
  231.  
  232.   startTicks = TickCount ();
  233.   for (long counter = 1; counter <= samplingIterations; ++ counter)
  234.     ; //  NOTHING
  235.   endTicks = TickCount ();
  236.  
  237.   fSamplingIterations = samplingIterations;
  238.   fSamplingDuration = (endTicks - startTicks) / 60.0;
  239.  
  240.   fMilliSecIterations =
  241.     long (
  242.       samplingIterations / fSamplingDuration /
  243.       1000.0 / kSpeedFactorCorrection );
  244.   
  245.   fMachineSpeedFactor =
  246.     //  smaller than 1.0 for machines slower than the reference
  247.     (samplingIterations / fSamplingDuration)
  248.       /
  249.     (kReferenceIterations / kReferenceDuration);
  250.  
  251.   } //  TTiming :: TTiming
  252.  
  253.  
  254. // •------------------------------------------------------------------------
  255.  
  256. void TTiming :: Report (ostream & theStream)
  257.   {
  258.   theStream <<
  259.     "TTiming :: Report ()\n" <<
  260.     "   kSpeedFactorCorrection  = " << kSpeedFactorCorrection << "\n" <<
  261.     "   fMachineSpeedFactor     = " << fMachineSpeedFactor    << "\n" <<
  262.     "   fMilliSecIterations     = " << fMilliSecIterations    << "\n" <<
  263.     "   fSamplingIterations     = " << fSamplingIterations    << "\n" <<
  264.     "   fSamplingDuration       = " << fSamplingDuration      << "\n\n";
  265.   theStream <<
  266.     "On the reference machine, 'fMachineSpeedFactor' above gives\n"
  267.     "the adequate value of 'kSpeedFactorCorrection'!\n\n";
  268.   theStream . flush ();
  269.   } //  TTiming :: Report
  270.  
  271.  
  272. void TTiming :: MilliSecsDelay (long  theMilliSecsDelay)
  273.   {
  274.   const   long      limit =
  275.     theMilliSecsDelay * fMilliSecIterations;
  276.  
  277.   for (long counter = 1; counter <= limit; ++ counter)
  278.     ; //  NOTHING
  279.  
  280.   } //  TTiming :: MilliSecsDelay
  281.  
  282.  
  283. void TTiming :: Ten4SecsDelay (long theTen4SecsDelay)
  284.   //  used to obtain tenth's of a milli-second delays
  285.   {
  286.   const   long      limit =
  287.     long (theTen4SecsDelay * fMilliSecIterations / 10.0);
  288.  
  289.   for (long counter = 1; counter <= limit; ++ counter)
  290.     ; //  NOTHING
  291.  
  292.   } //  TTiming :: Ten4SecsDelay
  293.  
  294.  
  295. // •------------------------------------------------------------------------
  296.  
  297. void TTiming :: SampleTiming (ostream & theStream)
  298.   //  used to tune "kReferenceDuration"
  299.   {
  300.   const   float   kDesiredDuration = 10.0;  //  secs
  301.   
  302.   TTiming         theTiming;
  303.   long            startTicks, endTicks;
  304.   float           actualDuration, error;
  305.  
  306.   theTiming.Report (theStream);
  307.   
  308.   theStream << 
  309.     "*** Let's start looping " << kReferenceIterations << " times ! ***\n\n";
  310.   theStream . flush ();
  311.  
  312.   startTicks = TickCount ();
  313.  
  314.   for (long counter = 1; counter <= kReferenceIterations; ++ counter)
  315.     ; //  NOTHING
  316.  
  317.   endTicks = TickCount ();
  318.  
  319.   actualDuration = (endTicks - startTicks) / 60.0;
  320.   error = 100 * (actualDuration - kReferenceDuration) / kReferenceDuration;
  321.   
  322.   theStream <<
  323.     "kReferenceIterations = " << kReferenceIterations << "\n" <<
  324.     "kReferenceDuration   = " << kReferenceDuration   << "\n" <<
  325.     "actualDuration       = " << actualDuration       << " secs.\n" <<
  326.     "error                = " << error                << " %\n\n";
  327.   
  328.   theStream << "\n0 sec." << "\n";
  329.   theStream . flush ();
  330.  
  331.   SysBeep (1);
  332.   startTicks = TickCount ();
  333.  
  334.   theTiming.MilliSecsDelay (long (kDesiredDuration * 1000));
  335.  
  336.   endTicks = TickCount ();
  337.   SysBeep (1);
  338.  
  339.   actualDuration = (endTicks - startTicks) / 60.0;
  340.   error = 100.0 * (actualDuration - kDesiredDuration) / kDesiredDuration;
  341.  
  342.   theStream <<
  343.     "kDesiredDuration     = " << kDesiredDuration     << " secs.\n" <<
  344.     "actualDuration       = " << actualDuration       << " secs.\n" <<
  345.     "error                = " << error                << " %\n\n";
  346.   
  347.   theStream << "\n*** That's all folks! ***" << "\n\n";
  348.   theStream . flush ();
  349.  
  350.   } //  TTiming :: SampleTiming
  351.  
  352.  
  353. // •------------------------------------------------------------------------
  354.  
  355. -- 
  356. Jacques Menu
  357. Office Informatique
  358. Service des Hospices Cantonaux
  359. 1011 - Lausanne
  360. Switzerland
  361.  
  362. +++++++++++++++++++++++++++
  363.  
  364. >From rickgenter@aol.com (RickGenter)
  365. Date: 20 Dec 1995 09:12:41 -0500
  366. Organization: America Online, Inc. (1-800-827-6364)
  367.  
  368. >>>
  369. My question: is this what is done by other games? Is there an easier
  370. way of determining from the processor type and speed how much fps a
  371. given machine can achieve?
  372. <<<
  373.  
  374. For IndyCar Racing II, we monitor the frame rate and adjust graphics
  375. detail accordingly. We don't aim for a constant frame rate, but we let the
  376. user choose what they want for a minimum/maximum frame rate. If the frame
  377. rate exceeds the maximum, we turn on more detail. If the frame rate drops
  378. below minimum, we turn off some detail.
  379.  
  380. Rick Genter
  381. Technical Lead, IndyCar Racing II
  382. Papyrus Design Group, Inc.
  383.  
  384. ---------------------------
  385.  
  386. >From nagle@netcom.com (John Nagle)
  387. Subject: Async I-O, timer routines, on Power PCs - where documented?
  388. Date: Tue, 19 Dec 1995 07:13:08 GMT
  389. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  390.  
  391.       There are a few system calls, such as I/O completion routines and
  392. Time Manager routines, that have calling sequences which use specific
  393. 68K registers.  Obviously it's different on PowerPCs.  But where are
  394. the PPC interfaces documented?  IM (both paper and CD-ROM) is out of
  395. date, and "PowerPC System Software" doesn't help.  Anybody know?
  396. Thanks.
  397.  
  398.                                         John Nagle
  399.  
  400.      
  401.  
  402.  
  403.  
  404.  
  405. +++++++++++++++++++++++++++
  406.  
  407. >From wysocki@netcom.com (Chris Wysocki)
  408. Date: Tue, 19 Dec 1995 17:14:32 GMT
  409. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  410.  
  411. In article <nagleDJto1w.L4r@netcom.com>, John Nagle <nagle@netcom.com> wrote:
  412.  
  413. >      There are a few system calls, such as I/O completion routines and
  414. >Time Manager routines, that have calling sequences which use specific
  415. >68K registers.  Obviously it's different on PowerPCs.  But where are
  416. >the PPC interfaces documented?  IM (both paper and CD-ROM) is out of
  417. >date, and "PowerPC System Software" doesn't help.  Anybody know?
  418. >Thanks.
  419.  
  420. Look at the uppXXXXProcInfo constants and the CallXXXXProc macros in
  421. the header files to determine how the 68K register parameters are
  422. passed to the PowerPC routines.  Since PowerPC uses a uniform set of
  423. calling conventions, the 68K register parameters will be passed to the
  424. routine as formal arguments, so a 68K I/O completion routine that
  425. looks like:
  426.  
  427. void IOCompletion68K(void)
  428. {
  429.     ParmBlkPtr pb = (ParmBlkPtr) GetA0();
  430.     /*...*/
  431. }
  432.  
  433. would be declared for PowerPC as:
  434.  
  435. void IOCompletionPPC(ParmBlkPtr pb)
  436. {
  437.     /*...*/
  438. }
  439.  
  440. Chris.
  441.  
  442. ---------------------------
  443.  
  444. >From mgrueter@aol.com (M Grueter)
  445. Subject: BalloonWriter? Resourcer? or...
  446. Date: 14 Dec 1995 20:25:40 -0500
  447. Organization: America Online, Inc. (1-800-827-6364)
  448.  
  449. I need to create some Balloon Help for my app. IM Help Manager talks in
  450. several places about BalloonWriter from APDA. I called APDA, and was told
  451. they no longer sell this product. Where can I get a copy? Is Resourcer
  452. better (easier) to do this with?
  453.  
  454. - Mike
  455.  
  456. +++++++++++++++++++++++++++
  457.  
  458. >From ckt@best.com (Chris Thomas)
  459. Date: Thu, 14 Dec 1995 20:34:49 -0800
  460. Organization: Echo Software
  461.  
  462. In article <4aqiqk$5vb@newsbf02.news.aol.com>, mgrueter@aol.com (M
  463. Grueter) wrote:
  464.  
  465. > I need to create some Balloon Help for my app. IM Help Manager talks in
  466. > several places about BalloonWriter from APDA. I called APDA, and was told
  467. > they no longer sell this product. Where can I get a copy? Is Resourcer
  468. > better (easier) to do this with?
  469.  
  470. To be perfectly honest, the easiest way to do Balloon Help is Rez.
  471. Resorcerer can do it, though.  BalloonWriter doesn't work.
  472.  
  473. -- 
  474. Chris Thomas, ckt@best.com
  475.  
  476. +++++++++++++++++++++++++++
  477.  
  478. >From andyb@oasis.novia.net (Andy Bachorski)
  479. Date: Fri, 15 Dec 1995 09:51:34 -0600
  480. Organization: HardCopy, Inc.
  481.  
  482. In article <4aqiqk$5vb@newsbf02.news.aol.com>, mgrueter@aol.com (M
  483. Grueter) wrote:
  484.  
  485. > I need to create some Balloon Help for my app. IM Help Manager talks in
  486. > several places about BalloonWriter from APDA. I called APDA, and was told
  487. > they no longer sell this product. Where can I get a copy? Is Resourcer
  488. > better (easier) to do this with?
  489.  
  490. If you are using CodeWarrior, there is a freeware balloon help compiler
  491. available, written by Tim Enders. You can find it on metrowerks site
  492. <http://www.metrowerks.com>.
  493.  
  494. Andy B
  495.  
  496. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  497. Andy Bachorski * HardCopy, Inc. * andyb@oasis.novia.net
  498.  
  499. +++++++++++++++++++++++++++
  500.  
  501. >From munz@wordperfect.com (Mark Munz)
  502. Date: Fri, 15 Dec 1995 10:08:55 -0700
  503. Organization: (none)
  504.  
  505. In article <4aqiqk$5vb@newsbf02.news.aol.com>, mgrueter@aol.com (M
  506. Grueter) wrote:
  507.  
  508. > I need to create some Balloon Help for my app. IM Help Manager talks in
  509. > several places about BalloonWriter from APDA. I called APDA, and was told
  510. > they no longer sell this product. Where can I get a copy? Is Resourcer
  511. > better (easier) to do this with?
  512. > - Mike
  513.  
  514. I've found Resourcer's templates easy enough to work with. I use it to
  515. write any balloon help I require. Just my $0.02 worth.
  516.  
  517. Mark Munz
  518.  
  519. +++++++++++++++++++++++++++
  520.  
  521. >From ingemar@lysator.liu.se (Ingemar Ragnemalm)
  522. Date: 17 Dec 1995 10:01:23 GMT
  523. Organization: (none)
  524.  
  525. ckt@best.com (Chris Thomas) writes:
  526.  
  527. >In article <4aqiqk$5vb@newsbf02.news.aol.com>, mgrueter@aol.com (M
  528. >Grueter) wrote:
  529.  
  530. >> I need to create some Balloon Help for my app. IM Help Manager talks in
  531. >> several places about BalloonWriter from APDA. I called APDA, and was told
  532. >> they no longer sell this product. Where can I get a copy? Is Resourcer
  533. >> better (easier) to do this with?
  534.  
  535. >To be perfectly honest, the easiest way to do Balloon Help is Rez.
  536. >Resorcerer can do it, though.  BalloonWriter doesn't work.
  537.  
  538. BalloonWriter works. It isn't the most bug-free software I've seen, but
  539. it definitely works, and I think it is pretty good for hacking in a few
  540. balloons quickly.
  541.  
  542. --
  543. - -
  544. Ingemar Ragnemalm, PhD
  545. Image processing, Mac shareware games
  546. E-mail address: ingemar@isy.liu.se or ingemar@lysator.liu.se
  547.  
  548. +++++++++++++++++++++++++++
  549.  
  550. >From ckt@best.com (Chris Thomas)
  551. Date: Wed, 20 Dec 1995 20:55:33 -0800
  552. Organization: Echo Software
  553.  
  554. In article <4b0ppk$nb4@newsy.ifm.liu.se>, ingemar@lysator.liu.se (Ingemar
  555. Ragnemalm) wrote:
  556.  
  557. > ckt@best.com (Chris Thomas) writes:
  558. > >In article <4aqiqk$5vb@newsbf02.news.aol.com>, mgrueter@aol.com (M
  559. > >Grueter) wrote:
  560. > >> I need to create some Balloon Help for my app. IM Help Manager talks in
  561. > >> several places about BalloonWriter from APDA. I called APDA, and was told
  562. > >> they no longer sell this product. Where can I get a copy? Is Resourcer
  563. > >> better (easier) to do this with?
  564. > >To be perfectly honest, the easiest way to do Balloon Help is Rez.
  565. > >Resorcerer can do it, though.  BalloonWriter doesn't work.
  566. > BalloonWriter works. It isn't the most bug-free software I've seen, but
  567. > it definitely works, and I think it is pretty good for hacking in a few
  568. > balloons quickly.
  569.  
  570. Wait a minute, now.  BalloonWriter *doesn't* work on my PowerMac 7100.
  571.  
  572. -- 
  573. Chris Thomas, ckt@best.com
  574.  
  575. ---------------------------
  576.  
  577. >From kaw11@cornell.edu (Kevin A. Walsh)
  578. Subject: Code Compiling on the fly? [PPC]
  579. Date: 17 Dec 1995 19:48:14 GMT
  580. Organization: Cornell University
  581.  
  582. Hi,
  583. I was wondering if this could be done:
  584.  
  585. I want to implement a very small compiler into a program. The compiler
  586. would not do much other than just mathematical formulas, and maybe some
  587. very simple branches or something.  Anyway, the resulting code from these
  588. short programs would be very standardized, so the compiler would be fairly
  589. easy to write.
  590.  
  591. Now, once i have the compiled PPC code, say in an array of longs or
  592. something, is it possible to cast this to a function, and call it durring
  593. runtime?
  594.  
  595. I have read somewhere (IM maybe) that with VM, Instruction Memory is read
  596. only. But, this does not really specifically prohibit writing code, and
  597. then transforming it into a read only Instruction Memory.  hmmm....
  598.  
  599. The result would be that you type in a simple expression
  600. (algebra/trig/...) using a standard form (ie, predefined variables x,y,z
  601. or something). The program compiles this to a short sequence of PPC
  602. instructions in an array of longs. Then, you can just call this repeatedly
  603. to iterate the function. This would in effect be like having built in
  604. support for all possible simple functions, because there would be no extra
  605. overhead once you go going!
  606.  
  607. So, imposible or what?
  608.  
  609. Thanks,
  610. -kev
  611. (email also please... kaw11@cornell.edu)
  612.  
  613. +++++++++++++++++++++++++++
  614.  
  615. >From "Andrew C. Plotkin" <erkyrath+@CMU.EDU>
  616. Date: Sun, 17 Dec 1995 19:13:25 -0500
  617. Organization: Carnegie Mellon, Pittsburgh, PA
  618.  
  619. kaw11@cornell.edu (Kevin A. Walsh) writes:
  620. > I want to implement a very small compiler into a program. The compiler
  621. > would not do much other than just mathematical formulas, and maybe some
  622. > very simple branches or something.  Anyway, the resulting code from these
  623. > short programs would be very standardized, so the compiler would be fairly
  624. > easy to write.
  625. > Now, once i have the compiled PPC code, say in an array of longs or
  626. > something, is it possible to cast this to a function, and call it durring
  627. > runtime?
  628.  
  629. Sure. You'd want to flush the caches (data and instruction) before you
  630. called it. And obviously you'd have to use the same calling convention
  631. as your compiler, but that should be in the compiler docs somewhere.
  632. > I have read somewhere (IM maybe) that with VM, Instruction Memory is read
  633. > only. But, this does not really specifically prohibit writing code, and
  634. > then transforming it into a read only Instruction Memory.  hmmm....
  635.  
  636. You can't transform writable memory into into read-only memory (or, at
  637. least, it's not necessary.) You'd be calling the code in writable
  638. memory. There's nothing wrong with this, as long as you flush caches. 
  639.  
  640. --Z
  641.  
  642. "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
  643.  
  644. +++++++++++++++++++++++++++
  645.  
  646. >From tim@apple.com (Tim Olson)
  647. Date: 20 Dec 1995 16:08:01 GMT
  648. Organization: Apple Computer, Inc. / Somerset
  649.  
  650. In article <kaw11-1712951450030001@132.236.178.23>
  651. kaw11@cornell.edu (Kevin A. Walsh) writes:
  652.  
  653.  
  654. > Now, once i have the compiled PPC code, say in an array of longs or
  655. > something, is it possible to cast this to a function, and call it durring
  656. > runtime?
  657.  
  658. Yes.  However, before you try to execute it, you must make sure the
  659. processor's instruction and data caches are coherent.  There is a
  660. system routine called "MakeDataExecutable" (or something like that)
  661. which you should call to do this.
  662.  
  663.         -- Tim Olson
  664.         Apple Computer, Inc. / Somerset
  665.         tim@apple.com
  666.  
  667. +++++++++++++++++++++++++++
  668.  
  669. >From chanson@mcs.com (Chris Hanson)
  670. Date: Fri, 22 Dec 1995 22:59:08 -0600
  671. Organization: MCSNet Internet Services
  672.  
  673. In article <Ekp=8Zm00WB7M9bn5H@andrew.cmu.edu>, "Andrew C. Plotkin"
  674. <erkyrath+@CMU.EDU> wrote:
  675.  
  676. >Sure. You'd want to flush the caches (data and instruction) before you
  677. >called it. And obviously you'd have to use the same calling convention
  678. >as your compiler, but that should be in the compiler docs somewhere.
  679.  
  680. Actually, it's in Inside Macintosh: PowerPC System Software.  But yeah.
  681.  
  682. Also, y'all might want to check out the latest release of PowerLisp (at
  683. <http://www.crl.com:80/~rgcorman/>) -- it's got a PowerPC assembler and
  684. compiler in Common Lisp source code.  Pretty cool.
  685.  
  686. TTFN,
  687. Chris
  688.  
  689. PS - Hi Zarf!
  690. - -
  691. chanson@mcs.com (Chris Hanson, KSC)
  692. "I always find my self wondering how people who can't code manage to
  693.  get through life." -Steve Gifford
  694.  
  695. ---------------------------
  696.  
  697. >From kriegsman@tr.org (Mark Kriegsman)
  698. Subject: Creating AE "whose" clause (using formTest) from C?
  699. Date: Thu, 14 Dec 1995 11:56:59 -0500
  700. Organization: The Internet Access Company
  701.  
  702. Summary:
  703.  
  704.    Has anyone every actually written code that create AE object specifiers
  705.    that use the formTest / typeObjectBeingExamined business in C or C++?
  706.  
  707.  
  708. I've read IM Interapplication Communication from cover to cover, and 
  709. in general I'm a patient person and I sometimes have a clue; but somebody 
  710. has decided that this week it's my turn to go nuts for a little while...
  711.  
  712. I'm converting an applescript widget to C, and I've got everything else
  713. working fine EXCEPT for the "whose" clause, which IMIAC describes in some 
  714. detail as using the formTest / typeObjectBeingExamined coupling.  I think
  715. I'm doing it just like the book shows (don't we all think this?), but I
  716. just can't get back any useful result from the target app.
  717.  
  718. In AppleScript, the code says:
  719.  
  720.   tell application "FileMaker Pro"
  721.      set matchedRecords to every Record of Database "people database" 
  722.                            whose Cell "lastname" contains "kriegsman"
  723.   end tell
  724.  
  725.  
  726. I can send AEs to FMP just fine, thanks, and the results come back
  727. beautifully -- unless I try to compose a "whose" clause (formTest / 
  728. typeObjectBeingExamined). I just can't seem a compose a "whose" clause 
  729. that actually works.  
  730.  
  731. I think I'm confused about the nesting of the 'exmn' descriptor 
  732. inside the object specifier, and I can't even find one single example of 
  733. actual C code that uses an 'exmn' descriptor anywhere on the net, on the 
  734. CodeWarrior CDs, on the Apprentice CD, or pretty much anywhere at all.
  735.  
  736. So, have you even done this or seen it done, and can you share some insights?
  737.  
  738. Please drop me a note at kriegsman@tr.org and/or post to the group if it
  739. seems appropriate.
  740.  
  741. Thanks very much...
  742.  
  743. -Mark
  744.  
  745. -- 
  746. Mark Kriegsman
  747. kriegsman@tr.org
  748. http://www.tr.org/users/mek/
  749.  
  750. +++++++++++++++++++++++++++
  751.  
  752. >From andyb@oasis.novia.net (Andy Bachorski)
  753. Date: Thu, 14 Dec 1995 17:00:29 -0600
  754. Organization: HardCopy, Inc.
  755.  
  756. In article <kriegsman-1412951156590001@www.tr.org>, kriegsman@tr.org (Mark
  757. Kriegsman) wrote:
  758.  
  759. >    Has anyone every actually written code that create AE object specifiers
  760. >    that use the formTest / typeObjectBeingExamined business in C or C++?
  761. >... snip ....
  762. > So, have you even done this or seen it done, and can you share some insights?
  763. > Please drop me a note at kriegsman@tr.org and/or post to the group if it
  764. > seems appropriate.
  765.  
  766.  
  767. Mark,
  768.  
  769. There's an article in the latest develop magazine (vol 24) that covers how
  770. to handle a whose clause in an app. Don't know if it will have what you're
  771. looking for, as I've not read it yet.
  772.  
  773. Andy B
  774.  
  775. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  776. Andy Bachorski * HardCopy, Inc. * andyb@oasis.novia.net
  777.  
  778. +++++++++++++++++++++++++++
  779.  
  780. >From bc@wetware.com (bill coderre)
  781. Date: Thu, 14 Dec 1995 19:25:22 -0800
  782. Organization: GRAFIX::CODERRE
  783.  
  784. kriegsman@tr.org (Mark Kriegsman) wrote:
  785. | Summary:
  786. |    Has anyone every actually written code that create AE object specifiers
  787. |    that use the formTest / typeObjectBeingExamined business in C or C++?
  788.  
  789. Funny how this works.
  790.  
  791. _develop_ 24, just out, has this as the topic of its lead article.
  792.  
  793. If you aren't already reading that article, well, you should drop
  794. everything and get it.
  795.  
  796. bc
  797.  
  798.  
  799. +++++++++++++++++++++++++++
  800.  
  801. >From gwatts@fnal.fnal.gov (Gordon Watts)
  802. Date: Thu, 14 Dec 1995 23:06:12 -0600
  803. Organization: Brown University
  804.  
  805. In article <kriegsman-1412951156590001@www.tr.org>, kriegsman@tr.org (Mark
  806. Kriegsman) wrote:
  807.  
  808. >Summary:
  809. >
  810. >   Has anyone every actually written code that create AE object specifiers
  811. >   that use the formTest / typeObjectBeingExamined business in C or C++?
  812. >
  813. >
  814. >I've read IM Interapplication Communication from cover to cover, and 
  815. >in general I'm a patient person and I sometimes have a clue; but somebody 
  816. >has decided that this week it's my turn to go nuts for a little while...
  817.  
  818. I seem to get more than my share of those weeks.  :-) I recently had
  819. trouble with the Get Data apple event (!).  There are several tools around
  820. that can help you out.  One is AETracker -- it is in the tool chest on the
  821. apple server (I down loaded the thing just recently).  It will trap
  822. *every* damm  call made to the ae manager.  I told it to give me lots of
  823. info from the script editor, and then ran my script with the "get data" in
  824. it.  I could see most of the descriptors being built and was able to
  825. figure out what I was doing wrong.
  826.  
  827. I'm not sure how useful it will be for a complex apple event like the one
  828. you describe, but it might give you that one "clue" you've been missing
  829. (search the log file for the typeObjectBeingExamined characters...).
  830.  
  831. I've also heard of a tool that will trap every apple event that goes back
  832. and forth (via the recording feature) and do a text dump of all the
  833. descriptors and data in the event.  I can't remember the name, or where I
  834. read about it.  But that would be ideal in this case, as it would show you
  835. the exact nesting that the script editor used.  Perhaps someone will read
  836. this and recall (or Jon Pugh (sp?) will know?).
  837.  
  838. Good luck.
  839.  
  840.    Cheers,
  841.       Gordon.
  842.  
  843. -- 
  844. gwatts@fnal.fnal.gov
  845.  
  846. +++++++++++++++++++++++++++
  847.  
  848. >From aznemeng@godzilla.zeta.org.au (Andrew Nemeth)
  849. Date: 15 Dec 1995 07:13:28 GMT
  850. Organization: Kralizec Dialup Unix
  851.  
  852. Mark Kriegsman (kriegsman@tr.org) wrote:
  853. : Summary:
  854.  
  855. : I'm converting an applescript widget to C, and I've got everything else
  856. : working fine EXCEPT for the "whose" clause, which IMIAC describes in some 
  857. : detail as using the formTest / typeObjectBeingExamined coupling.  I think
  858. : I'm doing it just like the book shows (don't we all think this?), but I
  859. : just can't get back any useful result from the target app.
  860.  
  861. : In AppleScript, the code says:
  862.  
  863. :   tell application "FileMaker Pro"
  864. :      set matchedRecords to every Record of Database "people database" 
  865. :                            whose Cell "lastname" contains "kriegsman"
  866. :   end tell
  867.  
  868. For such complicated AE activity, programming via the OSL is a self-
  869. defeating activity.  You could do it, but the code you will end up 
  870. writing will be so convoluted that it would be almost impossible to 
  871. maintain and upgrade.
  872.  
  873. Only use the OSL for 'simple' AE stuff, and not to replace great 
  874. swathes of activity which should really be performed in AppleScript.
  875.  
  876. Presumably you want to convert to C/OSL in order to increase runtime speed.
  877. Take a look at my 'OSA_Runner.sit.hqx' code at info-mac/dev/src (or my
  878. home page at 'http://www.zeta.org.au/~aznemeng') to show how to run
  879. Applescripts (fast!) from within applications, with or without variables
  880. supplied at run time.
  881.  
  882. Don't be put off by AppleScript.  Provided you 'tweak' it the right way,
  883. the run-time speed is only slightly slower than direct OSL calls - without
  884. the heartache.
  885.  
  886. Andrew Nemeth
  887. http://www.zeta.org.au/~aznemeng
  888. "Team Players are Corporate Moonies"
  889.  
  890.  
  891. +++++++++++++++++++++++++++
  892.  
  893. >From pottier@drakkar.ens.fr (Francois Pottier)
  894. Date: 15 Dec 1995 12:56:58 GMT
  895. Organization: Ecole Normale Superieure, Paris
  896.  
  897. In article <kriegsman-1412951156590001@www.tr.org>,
  898. Mark Kriegsman <kriegsman@tr.org> wrote:
  899.  
  900. >   Has anyone every actually written code that create AE object specifiers
  901. >   that use the formTest / typeObjectBeingExamined business in C or C++?
  902.  
  903. I have done it inside my own application (it supports "whose" clauses and
  904. is recordable, so it has to build these events and send them to itself).
  905.  
  906. Unfortunately, I don't have my code at hand, but here's a piece of advice
  907. which might be useful. Instead of sending your events to FileMaker Pro,
  908. send them to your own app and turn recording on. This way, your events
  909. will be recorded and you will be able to use the Script Editor to see what
  910. they look like in human-readable form.
  911.  
  912. I hope this helps,
  913.  
  914. -- 
  915. Francois
  916. pottier@dmi.ens.fr
  917. http://www.eleves.ens.fr:8080/home/pottier/
  918.  
  919. +++++++++++++++++++++++++++
  920.  
  921. >From monhacker@aol.com (MonHacker)
  922. Date: 15 Dec 1995 09:26:54 -0500
  923. Organization: America Online, Inc. (1-800-827-6364)
  924.  
  925.  
  926.  
  927. In article <kriegsman-1412951156590001@www.tr.org>, kriegsman@tr.org (Mark
  928. Kriegsman) wrote:
  929.  
  930. >Summary:
  931. >
  932. >   Has anyone every actually written code that create AE object
  933. specifiers
  934. >   that use the formTest / typeObjectBeingExamined business in C or C++?
  935. >
  936. >
  937. >I've read IM Interapplication Communication from cover to cover, and 
  938. >in general I'm a patient person and I sometimes have a clue; but somebody
  939.  
  940. >has decided that this week it's my turn to go nuts for a little while...
  941.  
  942. Mark,
  943.  
  944. You may want to consider using AEGizmos.  When I get a compex AE the first
  945. thing I do is send it from Script Editor or Scripter and then use the
  946. AEPrint function inside the application to see what it looks like (in all
  947. it's glory).  Later, when I want to recreate such a beast, I just turn
  948. that same AEGizmo string loose on the AEBuild function and ... bingo - I
  949. have the AE in it's correct form.  One note of caution - there may be a
  950. bug in the AEPrint function ... when you run with QC it is detecting a
  951. 'write past end of block' condition.  Someday I'll have to dig into this a
  952. little deeper.
  953.  
  954. Good Luck,
  955. Bob Boylan
  956.  
  957. +++++++++++++++++++++++++++
  958.  
  959. >From andyb@oasis.novia.net (Andy Bachorski)
  960. Date: Fri, 15 Dec 1995 09:46:56 -0600
  961. Organization: HardCopy, Inc.
  962.  
  963. In article <kriegsman-1412951156590001@www.tr.org>, kriegsman@tr.org (Mark
  964. Kriegsman) wrote:
  965.  
  966. >Summary:
  967. >
  968. >   Has anyone every actually written code that create AE object specifiers
  969. >   that use the formTest / typeObjectBeingExamined business in C or C++?
  970. >
  971. >
  972. >I've read IM Interapplication Communication from cover to cover, and 
  973. >in general I'm a patient person and I sometimes have a clue; but somebody 
  974. >has decided that this week it's my turn to go nuts for a little while...
  975.  
  976. Upon further reflection, why not just include the script itself in your
  977. app. You said that you have an equivalent AppleScript working already.
  978.  
  979. There is an article in one of the more recent MacTech magazines (sorry,
  980. don't remember which one) that shows a technique for embeding scripts in
  981. an app. There is also a new script compiler for CodeWarrior that was
  982. released by Gordon Watts <gwatts@fnal.fnal.gov>. Here is the text from the
  983. announcement. It sounds like what you are looking for. 
  984.  
  985. ... Just noticed he (Gordon) replied to your question as well. Wonder why
  986. he didn't mention this?
  987.  
  988. Andy B
  989.  
  990. =-=-=-=-=-=-=
  991.  
  992. From: gwatts@fnal.fnal.gov (Gordon Watts)
  993. Newsgroups: comp.sys.mac.programmer.codewarrior
  994. Subject: Script Builder 1.0
  995. Date: Wed, 13 Dec 1995 13:36:34 -0500
  996. Organization: Brown University
  997. Lines: 43
  998. Message-ID: <gwatts-1312951336340001@128.148.60.219>
  999. NNTP-Posting-Host: 128.148.60.219
  1000.  
  1001. Hi,
  1002.   Script Builder 1.0 is a free (small) plugin compiler for the CW7
  1003. environment that allows you to add compiled scripts (from the script
  1004. editor) to your project.
  1005.  
  1006.   I've been trying to see the light, and integrate applescript more
  1007. closely with my applications.  One thing I really hate writeing is the
  1008. choose document and send an apple event to open document code.  As long as
  1009. you don't need any thing fancy in the way of dialog boxes, you can do it
  1010. in apple script in a few lines.
  1011.  
  1012.   Cool -- but I don't want this script to be a seperate file that sits in
  1013. the application folder -- I want it to be a resource in my app.  Script
  1014. editor will compile scripts into a resource and has a nice interface, so I
  1015. leaveraged off of that, and wrote this small plug in that will allow you
  1016. to add compiled scripts to your project.  You must make a minor change to
  1017. your script and add a comment line containing a tag that has the resource
  1018. id number, but other than that, scripts can remain the same.
  1019.  
  1020.   I've also included a few classes I use to help me access these scripts
  1021. in my projects (pp projects, btw).  These objects take care of connecting
  1022. to a default script component, loading the script from a named resource,
  1023. and executing it (ignoring or returning AEDesc results).  They will throw
  1024. expections.  They have not, however, been carefully tested, so take care. 
  1025. All sample code is C++, but I'm more than happy to add pascal (or anything
  1026. else) to the archive if people will send me the snippits.
  1027.  
  1028.   There is a readme file included with installation instructions and a
  1029. show example of how to use the thing.  Let me know if there are any
  1030. problems (gwatts@fnal.fnal.gov).  Good luck.
  1031.  
  1032.   Oh -- I have submitted this to info-mac and other sites.  I suspect it
  1033. will appear today or tomorrow in the /dev area as script-builder-10...
  1034. wait, let me check... no, it dosn't seem to be there yet.  I can't be sure
  1035. of the name: Igor will name it (perhaps later today).  I've also sent it
  1036. off to the metrowerks class library, but it isn't a class, so I'm not sure
  1037. if it will be included in that (I did that about 10 minutes ago).
  1038.  
  1039.    Cheers,
  1040.       Gordon.
  1041.  
  1042. -- 
  1043. gwatts@fnal.fnal.gov
  1044.  
  1045. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  1046. Andy Bachorski * HardCopy, Inc. * andyb@oasis.novia.net
  1047.  
  1048. +++++++++++++++++++++++++++
  1049.  
  1050. >From ck@be.com (C.K. Haun)
  1051. Date: Fri, 15 Dec 1995 10:11:36 -0800
  1052. Organization: Be, Inc.
  1053.  
  1054. In article <kriegsman-1412951156590001@www.tr.org>, kriegsman@tr.org (Mark 
  1055. >    Has anyone every actually written code that create AE object specifiers
  1056. >    that use the formTest / typeObjectBeingExamined business in C or C++?
  1057. Mark,
  1058. I actually don't think I've seen this either, but there is a solution.
  1059.  
  1060. Get my AETracker control panel and install it on your machine.
  1061. Restart
  1062. Run filemaker pro and the Script Editor
  1063. turn AETracker ON (see the docs)
  1064. Send the applescript you want to analyze
  1065. Turn off AETracker
  1066. Go into MPW (or your favorite Text Editor) and open the log file that
  1067. AETracker generated
  1068.  
  1069. Walk through it, and you'll see both exactly how the Script Editor built
  1070. the event, but also how FileMaker parsed it.  This has been invaluable to
  1071. me in understanding what objects and stuff an applicastion specifically is
  1072. looking for (standards?  Hah!)
  1073.  
  1074. CKH
  1075.  
  1076. +++++++++++++++++++++++++++
  1077.  
  1078. >From gwatts@fnal.fnal.gov (Gordon Watts)
  1079. Date: Sun, 17 Dec 1995 05:02:37 -0600
  1080. Organization: Brown University
  1081.  
  1082. In article <andyb-1512950946560001@kojak.novia.net>, andyb@oasis.novia.net
  1083. (Andy Bachorski) wrote:
  1084.  
  1085. >
  1086. >... Just noticed he (Gordon) replied to your question as well. Wonder why
  1087. >he didn't mention this?
  1088. >
  1089. >Andy B
  1090.  
  1091. Because he (Gordon) was very tired when he posted that note and it didn't
  1092. even occur to me: that's what happens when I do owl shifts. :-)
  1093.  
  1094.    Cheers,
  1095.       Gordon.
  1096.  
  1097. -- 
  1098. gwatts@fnal.fnal.gov
  1099.  
  1100. +++++++++++++++++++++++++++
  1101.  
  1102. >From sample@esltd.com (Don Sample)
  1103. Date: Wed, 20 Dec 1995 15:49:28 -0500
  1104. Organization: Enerprise Solutions Ltd
  1105.  
  1106. In article <kriegsman-1412951156590001@www.tr.org>, kriegsman@tr.org
  1107. (Mark>Kriegsman) wrote:
  1108.  
  1109. >Summary:
  1110. >
  1111. >   Has anyone every actually written code that create AE object specifiers
  1112. >   that use the formTest / typeObjectBeingExamined business in C or C++?
  1113. >
  1114. >
  1115. >I've read IM Interapplication Communication from cover to cover, and 
  1116. >in general I'm a patient person and I sometimes have a clue; but somebody 
  1117. >has decided that this week it's my turn to go nuts for a little while...
  1118. >
  1119.  
  1120. The latest issue of d e v e l o p may help you.  It has an article on the
  1121. opposite end of your problem...the processing of "whose" apple events. 
  1122. Maybe seeing how one is taken appart will tell you how to put one
  1123. together.
  1124.  
  1125. -- 
  1126. Don Sample (sample@esltd.com)           |  Quando Omni Flunkus
  1127. Enterprise Solutions Ltd.               |        Moritati
  1128. http://www.esltd.com/esl_people/sample/ |
  1129.  
  1130. +++++++++++++++++++++++++++
  1131.  
  1132. >From wombat@claris.com (Scott Lindsey)
  1133. Date: Thu, 21 Dec 1995 16:52:29 -0800
  1134. Organization: Claris Corp., Vancouver WA
  1135.  
  1136. In article <kriegsman-1412951156590001@www.tr.org>, kriegsman@tr.org (Mark
  1137. Kriegsman) wrote:
  1138.  
  1139. >Summary:
  1140. >
  1141. >   Has anyone every actually written code that create AE object specifiers
  1142. >   that use the formTest / typeObjectBeingExamined business in C or C++?
  1143. >
  1144. >
  1145. >I've read IM Interapplication Communication from cover to cover, and 
  1146. >in general I'm a patient person and I sometimes have a clue; but somebody 
  1147. >has decided that this week it's my turn to go nuts for a little while...
  1148. >
  1149. >I'm converting an applescript widget to C, and I've got everything else
  1150. >working fine EXCEPT for the "whose" clause, which IMIAC describes in some 
  1151. >detail as using the formTest / typeObjectBeingExamined coupling.  I think
  1152. >I'm doing it just like the book shows (don't we all think this?), but I
  1153. >just can't get back any useful result from the target app.
  1154.  
  1155. To see just what you're getting, try sending the events to yourself with
  1156. the kAEDontExecute flag set, and record it with your favorite script
  1157. editor.  This will generate the canonical AppleScript for the AppleEvent
  1158. that you sent.
  1159.  
  1160. Here's some pidgen code that corresponds to what works for me.  This
  1161. particular example generates
  1162.  
  1163. every dbRecord of document 1 whose visible is true
  1164.  
  1165. which probably isn't particularly valid for FileMaker, but hey, this is
  1166. just an example.
  1167.  
  1168.  
  1169. OSErr BuildWhoseDesc(const AEDesc *container, AEDesc *result)
  1170. {
  1171.     AEDesc testDesc;
  1172.     // container is something like "document 1 (of null)"
  1173.  
  1174.     err = BuildTestDesc(&testDesc);
  1175.  
  1176.     err = CreateObjSpecifier(cDBRecord, container, formTest,
  1177.                             &testDesc, true, result);
  1178.     return err;
  1179. }
  1180.  
  1181. OSErr BuildTestDesc(AEDesc *resultForm)
  1182. {
  1183.     OSErr err;
  1184.     AEDesc opDesc1, opDesc2, tmpDesc;
  1185.  
  1186.     tmpDesc.descriptorType = typeObjectBeingExamined;
  1187.     tmpDesc.dataHandle = NIL;
  1188.  
  1189.     // ... visible ...
  1190.     err = CreatePropertyDesc(&tmpDesc, pVisible, &opDesc1);
  1191.     if (!err)
  1192.     {
  1193.         Boolean aBool = TRUE;
  1194.  
  1195.         // ... true ...
  1196.         err = AECreateDesc(typeBoolean, &aBool, sizeof(Boolean), &opDesc2);
  1197.         
  1198.         if (!err)
  1199.         {
  1200.             // ... visible is true ...
  1201.             err = CreateCompDescriptor(kAEEquals, &opDesc1, &opDesc2,
  1202.                                         true, resultForm);
  1203.         }
  1204.     }
  1205.  
  1206.     return err;
  1207. }
  1208.  
  1209. -- 
  1210. Scott Lindsey <wombat@claris.com, wombat@apple.com>
  1211.  
  1212. ---------------------------
  1213.  
  1214. >From Tom Santos <tom@apple.com>
  1215. Subject: From FSSpec to DirID
  1216. Date: 20 Dec 1995 08:27:39 GMT
  1217. Organization: Apple Computer, Inc.
  1218.  
  1219. Here's my scenario:
  1220.  
  1221. I have an FSSpec of a directory named Stuff
  1222. I have a file called Neato.
  1223. Neato is located in Stuff.
  1224. I want to make an FSSpec of Neato.
  1225.  
  1226. I'm looking for a sane way of doing this.
  1227.  
  1228. I figure that if I could get the DirID of Stuff, I could
  1229. easily make an FSSpec of Neato.
  1230.  
  1231. Getting the DirID of Stuff is non-trivial.
  1232.  
  1233. Help.  I'm losing my mind.
  1234.  
  1235. -Tom-
  1236.  
  1237. +++++++++++++++++++++++++++
  1238.  
  1239. >From Patrick.Stadelmann@etudiants.unine.ch (Patrick Stadelmann)
  1240. Date: Wed, 20 Dec 1995 11:33:06 +0100
  1241. Organization: University of Neuchatel
  1242.  
  1243. In article <4b8hdr$mse@apple.com>, Tom Santos <tom@apple.com> wrote:
  1244.  
  1245. > Here's my scenario:
  1246. > I have an FSSpec of a directory named Stuff
  1247. > I have a file called Neato.
  1248. > Neato is located in Stuff.
  1249. > I want to make an FSSpec of Neato.
  1250. > I'm looking for a sane way of doing this.
  1251. > I figure that if I could get the DirID of Stuff, I could
  1252. > easily make an FSSpec of Neato.
  1253. > Getting the DirID of Stuff is non-trivial.
  1254. > Help.  I'm losing my mind.
  1255.  
  1256. 1) Get MoreFiles (from DTS sample code). It has a routine to get
  1257.    the DirID from a FSSpec
  1258.  
  1259. 2) You can call FSMakeFSSpec with volRef and parent IDfrom the FSSpec
  1260.    of Stuff, and name set to "\p:Stuff:Neato"
  1261.  
  1262. Hope this helps
  1263.  
  1264. Patrick
  1265.  
  1266. -- 
  1267. Patrick Stadelmann <Patrick.Stadelmann@etudiants.unine.ch>
  1268.  
  1269. +++++++++++++++++++++++++++
  1270.  
  1271. >From jimm@io.com (Jim Menard)
  1272. Date: 20 Dec 1995 21:57:05 GMT
  1273. Organization: Completely un-
  1274.  
  1275. In article <4b8hdr$mse@apple.com> Tom Santos <tom@apple.com> writes:
  1276.  
  1277.    I have an FSSpec of a directory named Stuff
  1278.    I have a file called Neato.
  1279.    Neato is located in Stuff.
  1280.    I want to make an FSSpec of Neato.
  1281.  
  1282. Pretty easy. Just append the string ":Neato" to the file spec's name, like
  1283. this (UNTESTED CODE ALERT):
  1284.  
  1285.         FSSpec stuffFileSpec;
  1286.         // Fill in stuffFileSpec; you said you already have this.
  1287.  
  1288.         FSSpec neatoFileSpec = stuffFileSpec;
  1289.         CopyPStr(neatoFileSpec, "\p:Neato", sizeof(neatoFileSpec.name));
  1290.         // Voila!
  1291.  
  1292. Jim
  1293. --
  1294. Jim Menard   jimm@io.com   http://www.io.com/~jimm/   Be, Inc. "Hairy Guy"
  1295. "Is 'anal-retentive' hyphenated?" -- Tech Writer (reported by Richard Wesley)
  1296.  
  1297. +++++++++++++++++++++++++++
  1298.  
  1299. >From browning@cu-online.com (Dr. Benway)
  1300. Date: Thu, 21 Dec 1995 09:55:17 -0600
  1301. Organization: Interzone
  1302.  
  1303. In article <4b8hdr$mse@apple.com>, Tom Santos <tom@apple.com> wrote:
  1304.  
  1305. > Here's my scenario:
  1306. > I have an FSSpec of a directory named Stuff
  1307. > I have a file called Neato.
  1308. > Neato is located in Stuff.
  1309. > I want to make an FSSpec of Neato.
  1310. > I'm looking for a sane way of doing this.
  1311. > I figure that if I could get the DirID of Stuff, I could
  1312. > easily make an FSSpec of Neato.
  1313. > Getting the DirID of Stuff is non-trivial.
  1314. > Help.  I'm losing my mind.
  1315. > -Tom-
  1316.  
  1317. Try using PBGetCatInfo.
  1318.  
  1319. procedure DirFSSpecToDirID(theSpec:FSSpec; var theDir:LONGINT);
  1320.  
  1321. var
  1322.   theCInfoPBRec: CInfoPBRec;
  1323.   theName: Str255;
  1324.   theErr: OSErr;
  1325.  
  1326. begin
  1327.   theName := theSpec.name; { ioNamePtr must be pointer to Str255 }
  1328.   with theCInfoPBRec do
  1329.     begin
  1330.       ioCompletion := NIL;
  1331.       ioNamePtr := @theName;
  1332.       ioVRefNum := theSpec.vRefNum;
  1333.       ioFDirIndex := 0;
  1334.       ioDrDirID := theSpec.parID;
  1335.     end;
  1336.   theErr := PBGetCatInfoSync(@theCInfoPBRec);
  1337.   if theErr = noErr then
  1338.     theDir := theCInfoPBRec.ioDrDirID
  1339.   else
  1340.     { handle error here } 
  1341. end;
  1342.  
  1343. That chunk of code should get the job done.
  1344.  
  1345. Doc
  1346.  
  1347. -- 
  1348. Dr. Benway :::::::::::::::::: Interzone
  1349. =======================================
  1350. *  I can feel the heat closing in...  *
  1351. =======================================
  1352. *       browning@cu-online.com        *
  1353. * http://www.cu-online.com/~browning/ *
  1354. =======================================
  1355.  
  1356. ---------------------------
  1357.  
  1358. >From pmth02jc@umassd.edu (Jim Correia)
  1359. Subject: Getting the Highlight color as set in the Color Control Panel?
  1360. Date: Wed, 20 Dec 1995 09:17:28 -0500
  1361. Organization: University of Massachusetts Dartmouth
  1362.  
  1363. How do I get the Highlight color as the person has set it in the Color
  1364. Control Panel?
  1365.  
  1366. Is there a straight forward way to do this?
  1367.  
  1368. Is there any way to do this?
  1369.  
  1370. Toolbox Assistant hasn't given me the answer...
  1371.  
  1372. Jim
  1373.  
  1374. -- 
  1375. Jim Correia
  1376. Software Developer
  1377. SimCalc Project
  1378.  
  1379. +++++++++++++++++++++++++++
  1380.  
  1381. >From francois-regis.degott@imag.fr (Fr. Degott)
  1382. Date: 20 Dec 1995 15:17:21 GMT
  1383. Organization: LMC-IMAG
  1384.  
  1385. In article <pmth02jc-2012950917440001@10.0.2.15>, pmth02jc@umassd.edu (Jim
  1386. Correia) wrote:
  1387.  
  1388. > How do I get the Highlight color as the person has set it in the Color
  1389. > Control Panel?
  1390. > Is there a straight forward way to do this?
  1391. > Is there any way to do this?
  1392. > Toolbox Assistant hasn't given me the answer...
  1393.  
  1394. Hi Jim,
  1395.  
  1396. the hilite color is defined in low memory, at $0DA0 (RGBColor var.).
  1397.  
  1398. the 'old' method is:
  1399.  
  1400. const HiliteRGB = $0DA0;
  1401. type RGBColorPtr = ^RGBColor;
  1402.  
  1403. var HiliteColor: RGBColor;
  1404.  
  1405. HiliteColor := RGBColorPtr(HiliteRGB)^;
  1406.  
  1407. the 'new' method is to use the LMGetHiliteRGB() procs.
  1408. defined in the LowMem.h (or .p) file (univ. headers).
  1409.  
  1410. procedure LMGetHiliteRGB (var hiliteRGBValue: RGBColor);
  1411.  
  1412. HTH
  1413. Bye
  1414. Fr
  1415. _____________________________________________________________________________
  1416. Fr. Degott (Francois-Regis.Degott@imag.fr)
  1417. LogiMath, Lab. LMC-IMAG - Grenoble - France
  1418.  
  1419. +++++++++++++++++++++++++++
  1420.  
  1421. >From Patrick.Stadelmann@etudiants.unine.ch (Patrick Stadelmann)
  1422. Date: Wed, 20 Dec 1995 17:12:54 +0100
  1423. Organization: University of Neuchatel
  1424.  
  1425. In article <pmth02jc-2012950917440001@10.0.2.15>, pmth02jc@umassd.edu (Jim
  1426. Correia) wrote:
  1427.  
  1428. > How do I get the Highlight color as the person has set it in the Color
  1429. > Control Panel?
  1430. > Is there a straight forward way to do this?
  1431. > Is there any way to do this?
  1432. > Toolbox Assistant hasn't given me the answer...
  1433.  
  1434. >From LowMem.h :
  1435.  
  1436. pascal void LMGetHiliteRGB(RGBColor *hiliteRGBValue);
  1437.  
  1438. Patrick
  1439.  
  1440. -- 
  1441. Patrick Stadelmann <Patrick.Stadelmann@etudiants.unine.ch>
  1442.  
  1443. +++++++++++++++++++++++++++
  1444.  
  1445. >From Matt Slot <fprefect@umich.edu>
  1446. Date: 21 Dec 1995 02:47:30 GMT
  1447. Organization: University of Michigan
  1448.  
  1449. Jim Correia, pmth02jc@umassd.edu writes:
  1450.  > How do I get the Highlight color as the person has set it in the Color
  1451.  > Control Panel?
  1452.  > 
  1453.  > Is there a straight forward way to do this?
  1454.  > 
  1455.  > Is there any way to do this?
  1456.  
  1457. You are probably trying to highlight some text or another screen object,
  1458. and want to draw the color yourself. However, the toolbox has simple
  1459. support for "doing the right thing" WRT highlighting.
  1460.  
  1461. Normally on B/W machines, highlighting involves inverting the afflicted
  1462. area with InvertRect()/InvertRgn. On ColorQD machines, you can simply
  1463. insert the following line of code just before the Invert:
  1464.  
  1465.         if (gHasColorQD) LMSetHiliteMode(LMGetHiliteMode() ^ 0x80);
  1466.  
  1467. ColorQD automatically checks this lomem global when going to do an Invert
  1468. operation, and if it is toggled (not set!) it will paint it with the
  1469. highlight color! This is a once only setting, so you need to do it before
  1470. each Invert/highlight call.
  1471.  
  1472. Enjoy,
  1473.  
  1474. Matt
  1475.  
  1476. * * * * * * * * * * * * * * * * * * * * * * * * * * ======================
  1477. *  Reality: Matt Slot                             *  Time is an illusion.
  1478. *  E-Mail:  mailto:fprefect@umich.edu             *  Lunchtime doubly so.
  1479. *  Web:     http://www.sils.umich.edu/~fprefect/  *     -- Douglas Adams
  1480. * * * * * * * * * * * * * * * * * * * * * * * * * * ======================
  1481.  
  1482. +++++++++++++++++++++++++++
  1483.  
  1484. >From chris_page@powertalk.claris.com (Chris Page)
  1485. Date: Thu, 21 Dec 1995 16:22:16 -0800
  1486. Organization: Claris Corporation
  1487.  
  1488. In article <pmth02jc-2012950917440001@10.0.2.15>, pmth02jc@umassd.edu (Jim
  1489. Correia) wrote:
  1490.  
  1491. > How do I get the Highlight color as the person has set it in the Color
  1492. > Control Panel?
  1493.  
  1494. As others have noted, you can read the low-memory global variable using
  1495. LMGetHiliteRGB(), or, better yet, you can use LMSetHiliteMode() to let
  1496. Color QuickDraw do the work of hiliting for you. But also note:
  1497.  
  1498. The system hilite color is stored in the low-memory global, but every
  1499. color port has its own hilite color variable and can use it to override
  1500. the low-memory value (CGrafPort has a handle, grafVars, to a GravVars
  1501. struct with a hiliteRGB field). Color QD will read this color from the
  1502. color port, not the global. If you want to read the color directly,
  1503. instead of using LMSetHiliteMode(), be sure to get the color from the
  1504. port, not from LMGetHiliteRGB().
  1505.  
  1506. -- 
  1507. Chris Page                      | Internet junk mail, advertisements,
  1508. Claris Corporation              | and SPAMs bite...
  1509. chris_page@powertalk.claris.com |            Cut it out! :-P
  1510.  
  1511. Disclaimer: opinions are not necessarily those of my employer
  1512.  
  1513. ---------------------------
  1514.  
  1515. >From kalash@starnine.com (Joe Kalash)
  1516. Subject: Help patching NewPtr on PPC?
  1517. Date: Thu, 21 Dec 1995 11:08:11 -0800
  1518. Organization: StarNine Technologines, Inc.
  1519.  
  1520. I was recently trying to track down a memory leak that occured only on a
  1521. PowerPC. As "leaks" wasn't being useful, I decided to write my own "stuff"
  1522. by patching the memory traps. I should have known better...
  1523.  
  1524. The code that follows will cheerfully set the trap, but strange things
  1525. then happen:
  1526.  
  1527. (1) When called from PowerPC land, I actually get the following arguments
  1528. to MyNewPtr:
  1529.  
  1530. MyNewPtr(long trapNum,long thing, long baseTrap, Size ByteCount)
  1531.  
  1532. That is I get 4 arguments, the first seems to be the specific trap
  1533. (NewPtrClear, NewPtrSys, ...) the second I suspect as being the enum of
  1534. the trap descriptor, the third seems to be a "base" trap (NewPtr in this
  1535. case), and the fourth is actually the ByteCount that I want.
  1536.  
  1537. (2) When called from 68k land, I get the byte count in the first argument,
  1538. as expected.
  1539.  
  1540. The combination is not nice. I suspect that I have the enum that describes
  1541. the trap wrong, but I have tried many variations (with kPascalStackBased,
  1542. kCStackBased, and the dispatched variations), all to no avail. Can anyone
  1543. please tell me what stupidity I am doing? While I have long past found the
  1544. leak, I would still like to get this patch to work (I have been able to
  1545. patch toolbox calls, without this hassle).
  1546.  
  1547. Side whine, WHY do I have to write the enum that describes this trap? WHY
  1548. aren't they all in a nice header file supplied by Apple so I don't have to
  1549. spend my time dicking with this? I refuese to believe that I am the only
  1550. person on Earth who has ever had a need to patch an OS trap.
  1551.  
  1552. -- 
  1553. Thanks,
  1554.  
  1555. Joe Kalash
  1556. StarNine Technologies, Inc.
  1557. kalash@starnine.com
  1558.  
  1559.  
  1560. # include   <Traps.h>
  1561. # include   <MixedMode.h>
  1562.  
  1563. enum {
  1564.    uppNewPtrTrapInfo = kRegisterBased
  1565.       | RESULT_SIZE(SIZE_CODE(sizeof(Ptr)))
  1566.       | REGISTER_RESULT_LOCATION(kRegisterA0)
  1567.       | REGISTER_ROUTINE_PARAMETER(1, kRegisterD0, SIZE_CODE(sizeof(Size))),
  1568.    uppNewHandleTrapInfo = kRegisterBased
  1569.       | RESULT_SIZE(SIZE_CODE(sizeof(Handle)))
  1570.       | REGISTER_RESULT_LOCATION(kRegisterA0)
  1571.       | REGISTER_ROUTINE_PARAMETER(1, kRegisterD0, SIZE_CODE(sizeof(Size))),
  1572.    uppDisposePtrTrapInfo = kRegisterBased
  1573.       | REGISTER_ROUTINE_PARAMETER(1, kRegisterA0, SIZE_CODE(sizeof(Ptr))),
  1574.    uppDisposeHandleTrapInfo = kRegisterBased
  1575.       | REGISTER_ROUTINE_PARAMETER(1, kRegisterA0, SIZE_CODE(sizeof(Handle)))
  1576. };
  1577.  
  1578. typedef UniversalProcPtr MemoryTrapUPP;
  1579.  
  1580. MemoryTrapUPP  __NewPtrTrapUPP = nil;
  1581. MemoryTrapUPP  __OldNewPtrTrap = nil;
  1582.  
  1583. Ptr   MyNewPtr(Size ByteCount);
  1584.  
  1585. Ptr
  1586. MyNewPtr(Size ByteCount)
  1587. {
  1588.    Ptr   retVal;
  1589.    
  1590.    retVal = (Ptr)
  1591. CallOSTrapUniversalProc(__OldNewPtrTrap,uppNewPtrTrapInfo,ByteCount);
  1592.    return (retVal);
  1593. }
  1594.  
  1595. main()
  1596. {
  1597.    __OldNewPtrTrap = (MemoryTrapUPP) NGetTrapAddress(_NewPtr,OSTrap);
  1598.    __NewPtrTrapUPP = NewRoutineDescriptor((ProcPtr) MyNewPtr,
  1599. uppNewPtrTrapInfo, kPowerPCISA);
  1600.    NSetTrapAddress((UniversalProcPtr) __NewPtrTrapUPP,_NewPtr,OSTrap);
  1601. }
  1602.  
  1603.  
  1604. +++++++++++++++++++++++++++
  1605.  
  1606. >From d88-bli@xbyse.nada.kth.se (Bo Lindbergh)
  1607. Date: 22 Dec 1995 01:43:57 GMT
  1608. Organization: Royal Institute of Technology, Stockholm, Sweden
  1609.  
  1610. In article <kalash-2112951108110001@boris.starnine.com> kalash@starnine.com (Joe Kalash) writes:
  1611. [description of horrors experienced while trying to patch an OS trap
  1612.  natively deleted]
  1613.  
  1614. Just about the only way to get this right is to disassemble the glue in
  1615. InterfaceLib to see what it does.  For NewPtr, it turns out to be this:
  1616.  
  1617.         mflr       r0
  1618.         stwu       SP,-0x0040(SP)
  1619.         stw        r0,0x0048(SP)
  1620.         ori        r6,r3,0x0000
  1621.         lis        r4,0x0003
  1622.         lis        r0,0x0001
  1623.         addic      r4,r4,0x3932
  1624.         subic      r5,r0,0x5EE2
  1625.         lwz        r3,0x0478(r0)
  1626.         bl         CallOSTrapUniversalProc
  1627.         lwz        RTOC,0x0014(SP)
  1628.         lwz        r12,0x0048(SP)
  1629.         stw        r3,0x0038(SP)
  1630.         mtlr       r12
  1631.         addic      SP,SP,0x0040
  1632.         blr
  1633.  
  1634. It calls CallOSTrapUniversalProc with four args:
  1635.  
  1636.         0x478 is the address of the OS trap table entry for NewPtr,
  1637.         so the first arg is the trap address for NewPtr.
  1638.  
  1639.         The second arg is 0x33932, which translates to this procInfo:
  1640.                 kRegisterBased
  1641.                 | REGISTER_RESULT_LOCATION(kRegisterA0)
  1642.                 | RESULT_SIZE(kFourByteCode)
  1643.                 | REGISTER_ROUTINE_PARAMETER(1,kRegisterD1,kFourByteCode)
  1644.                 | REGISTER_ROUTINE_PARAMETER(2,kRegisterD0,kFourByteCode)
  1645.  
  1646.         The third arg is 0xA11E, the trap value _NewPtr.  For a 68k
  1647.         routine, this goes into register d1 (which fits the calling
  1648.         convention for OS traps as described in IM).
  1649.  
  1650.         The fourth arg is the requested size.  For a 68k routine,
  1651.         this goes into register d0 (which fits the parameter pragma
  1652.         for NewPtr in <Memory.h>).
  1653.  
  1654. So a native patch of NewPtr should be declared like this:
  1655.  
  1656.         Ptr myNewPtr(unsigned long trapWord,Size size);
  1657.  
  1658. And the procInfo for its UPP as well as for the call through to
  1659. the old version should be this:
  1660.  
  1661.         kRegisterBased
  1662.         | REGISTER_RESULT_LOCATION(kRegisterA0)
  1663.         | RESULT_SIZE(SIZE_CODE(sizeof (Ptr)))
  1664.         | REGISTER_ROUTINE_PARAMETER(1,kRegisterD1,SIZE_CODE(sizeof (unsigned long)))
  1665.         | REGISTER_ROUTINE_PARAMETER(2,kRegisterD0,SIZE_CODE(sizeof (Size)))
  1666.  
  1667. Repeating the above for NewHandle, DisposePtr, and DisposeHandle is left
  1668. as an exercise for the search and replace function of your editor.
  1669.  
  1670. > Side whine, WHY do I have to write the enum that describes this trap? WHY
  1671. > aren't they all in a nice header file supplied by Apple so I don't have to
  1672. > spend my time dicking with this? I refuese to believe that I am the only
  1673. > person on Earth who has ever had a need to patch an OS trap.
  1674.  
  1675. If Apple told us how to patch OS traps natively, they'd have to
  1676. tell us how to patch dispatched toolbox traps natively too, and
  1677. _that_ process is too scary to describe on Usenet. :-)
  1678.  
  1679.  
  1680. /Bo Lindbergh
  1681.  
  1682. ---------------------------
  1683.  
  1684. >From ericd@ra.nilenet.com (Eric A. Drumbor)
  1685. Subject: Is delta copying effective?
  1686. Date: Fri, 24 Nov 1995 14:27:11 -0700
  1687. Organization: BW Software
  1688.  
  1689.      I've noticed that some of the more popular games (Hornet for
  1690. instance) are using a delta copy mode.  That is, the only pixels that are
  1691. copied to the screen are the pixels that have changed color from what is
  1692. on the screen.
  1693.  
  1694.      Does this really help?  I suppose it must to some degree, but it
  1695. seems like an awful lot of checking to see what has changed in the
  1696. offscreen pixmap.  After all the checking has taken place, and only the
  1697. changed (delta) pixels have been copied, it doesn't seem like there would
  1698. be much of a speed gain given the amount of checking (memory accesses, and
  1699. compares) that take place.
  1700.  
  1701.      Maybe I have the wrong idea on how to go about this, but it doesn't
  1702. seem worthwhile.  Does anyone have an opinion on the subject?  Please, by
  1703. all means, prove me wrong... ;-)
  1704.  
  1705. -- 
  1706. "Ah, voice come from cow on wall!"
  1707. Eric A. Drumbor      
  1708. ericd@ra.nilenet.com                 <http://www.nilenet.com/~ericd/>
  1709. BW Software
  1710.  
  1711. +++++++++++++++++++++++++++
  1712.  
  1713. >From mick@emf.net (Mick Foley)
  1714. Date: Fri, 24 Nov 1995 18:47:46 -0800
  1715. Organization: "emf.net" Quality Internet Access.  (510) 704-2929 (Voice)
  1716.  
  1717. In article <ericd-2411951427110001@slip18.nilenet.com>,
  1718. ericd@ra.nilenet.com (Eric A. Drumbor) wrote:
  1719.  
  1720. >      I've noticed that some of the more popular games (Hornet for
  1721. > instance) are using a delta copy mode.  That is, the only pixels that are
  1722. > copied to the screen are the pixels that have changed color from what is
  1723. > on the screen.
  1724. >      Does this really help?  I suppose it must to some degree, but it
  1725. > seems like an awful lot of checking to see what has changed in the
  1726. > offscreen pixmap.  After all the checking has taken place, and only the
  1727. > changed (delta) pixels have been copied, it doesn't seem like there would
  1728. > be much of a speed gain given the amount of checking (memory accesses, and
  1729. > compares) that take place.
  1730.  
  1731. The answer is: Yes it's worth it -- if you have a good way of keeping
  1732. track of what has changed and if you are willing to write directly to the
  1733. screen (or compose a small number of rects to CopyBits). You are right in
  1734. saying that comparing every pixel would be to slow. In flat shaded 3D
  1735. games (Hornet, A10, Spectre), one can keep a list of "color runs" and only
  1736. change the areas that have changed. In many sprite games, a list of
  1737. rectangles that have changed is maintainted and only those rectangles are
  1738. copied. A full 640 x 480 screen is 307K, a lot to move. With update rects
  1739. or a "color run" list, you can avoid moving most of that data. The savings
  1740. more than make up for the time to keep track of the update list.
  1741.  
  1742. Mick
  1743.  
  1744. +++++++++++++++++++++++++++
  1745.  
  1746. >From dwareing@adelaide.on.net (David Wareing)
  1747. Date: Sat, 25 Nov 1995 14:58:50 +1100
  1748. Organization: Weyland Yutani
  1749.  
  1750. In article <ericd-2411951427110001@slip18.nilenet.com>,
  1751. ericd@ra.nilenet.com (Eric A. Drumbor) wrote:
  1752.  
  1753. >     I've noticed that some of the more popular games (Hornet for
  1754. >instance) are using a delta copy mode.  That is, the only pixels that are
  1755. >copied to the screen are the pixels that have changed color from what is
  1756. >on the screen.
  1757. >
  1758. >     Does this really help?  I suppose it must to some degree, but it
  1759. >seems like an awful lot of checking to see what has changed in the
  1760. >offscreen pixmap.  After all the checking has taken place, and only the
  1761. >changed (delta) pixels have been copied, it doesn't seem like there would
  1762. >be much of a speed gain given the amount of checking (memory accesses, and
  1763. >compares) that take place.
  1764.  
  1765. Given Hornet's speed, I'd say that their drawing method is very efficient.
  1766. If you disable the debugger, run Hornet and then hit the programmer's
  1767. key, then dismiss the dialog, you can see Hornet's updating method in
  1768. action. It's very exacting in which pixels get updated. It's surprising
  1769. to see just how much *isn't* being changed on the screen each frame...
  1770.  
  1771. The brute force method would be to just update the whole window each
  1772. frame, but you'd have to think that virtually any decent delta algorithm
  1773. could provide speed improvements over that method.
  1774.  
  1775. -- 
  1776. David Wareing                                 dwareing@adelaide.on.net
  1777. Belair, South Australia           http://www.AmbrosiaSW.com/~dwareing/
  1778. Macintosh Games & Multimedia Programming
  1779.  
  1780.  
  1781. +++++++++++++++++++++++++++
  1782.  
  1783. >From songer@lexmark.com
  1784. Date: Mon, 27 Nov 1995 14:46:35 GMT
  1785. Organization: Lexmark International, Lexington, KY
  1786.  
  1787. In article <ericd-2411951427110001@slip18.nilenet.com> ericd@ra.nilenet.com (Eric A. Drumbor) writes:
  1788.  
  1789.    [...]
  1790.         Does this really help?  I suppose it must to some degree, but it
  1791.    seems like an awful lot of checking to see what has changed in the
  1792.    offscreen pixmap.  After all the checking has taken place, and only the
  1793.    changed (delta) pixels have been copied, it doesn't seem like there would
  1794.    be much of a speed gain given the amount of checking (memory accesses, and
  1795.    compares) that take place.
  1796.    [...]
  1797.  
  1798. Hi!
  1799.  
  1800.      Yes it helps. I use edge lists to maintain the update regions of
  1801. double buffer to screen. The only downside is that to really get the
  1802. best gain one needs a custom blitter that knows about edge lists.
  1803. (Read: "not copybits") One can, of course, express edge lists as a
  1804. series of rectangles and use CopyBits but depending on the edge list
  1805. regions, that can be pretty inefficient.
  1806.  
  1807. Anyway,
  1808. -Chris
  1809.  
  1810. +++++++++++++++++++++++++++
  1811.  
  1812. >From albtrssp@crocker.com (Kevin Tieskoetter)
  1813. Date: 24 Nov 1995 17:42:15 GMT
  1814. Organization: Albatross Productions
  1815.  
  1816. In article <ericd-2411951427110001@slip18.nilenet.com>
  1817. ericd@ra.nilenet.com (Eric A. Drumbor) writes:
  1818.  
  1819. >      Does this really help?  I suppose it must to some degree, but it
  1820. > seems like an awful lot of checking to see what has changed in the
  1821. > offscreen pixmap.  After all the checking has taken place, and only the
  1822. > changed (delta) pixels have been copied, it doesn't seem like there would
  1823. > be much of a speed gain given the amount of checking (memory accesses, and
  1824. > compares) that take place.
  1825.  
  1826. That's where the algorithm is really complicated. I believe they don't
  1827. actually check which pixels have changed, but rather do it on a
  1828. polygon-oriented level. I believe that it'll always end up copying by
  1829. triangles, but I could be wrong.
  1830. >      Maybe I have the wrong idea on how to go about this, but it doesn't
  1831. > seem worthwhile.  Does anyone have an opinion on the subject?  Please, by
  1832. > all means, prove me wrong... ;-)
  1833. It's very worthwhile, look at Hellcats - ran in full-screen 256-colors
  1834. on my old 16 Mhz '020 LC. However, I would imagine that as you get more
  1835. polygons in the database, it'll quickly slow down. It'll also not work
  1836. with texture-mapped or goraud-/phong- shaded polygons, since the same
  1837. color does not hold across the entire polygon. Therefore, it'll drop
  1838. out of use as machines get faster and games get more complex.
  1839.  
  1840.  
  1841. -kevin
  1842.  
  1843. //---------------------------------------------------------------------
  1844.    Kevin Tieskoetter / Software Prestidigitator, Specular International
  1845. //---------------------------------------------------------------------
  1846.  
  1847. +++++++++++++++++++++++++++
  1848.  
  1849. >From jmunkki@beta.hut.fi (Juri Munkki)
  1850. Date: 28 Nov 1995 15:03:21 GMT
  1851. Organization: Helsinki University of Technology
  1852.  
  1853. In article <49505n$nuh@dns.crocker.com> albtrssp@crocker.com (Kevin Tieskoetter) writes:
  1854. >That's where the algorithm is really complicated. I believe they don't
  1855. >actually check which pixels have changed, but rather do it on a
  1856. >polygon-oriented level. I believe that it'll always end up copying by
  1857. >triangles, but I could be wrong.
  1858. I think you are wrong about the triangles. I would expect that they get
  1859. a run length encoded data stream out from a scan converter, which they
  1860. then compare with what is currently shown on the screen. YX-P scan
  1861. converters are quite well understood and the algorithms can be found
  1862. in basic 3D computer graphics textbooks.
  1863.  
  1864. >It's very worthwhile, look at Hellcats - ran in full-screen 256-colors
  1865. >on my old 16 Mhz '020 LC. However, I would imagine that as you get more
  1866. >polygons in the database, it'll quickly slow down. It'll also not work
  1867. >with texture-mapped or goraud-/phong- shaded polygons, since the same
  1868. >color does not hold across the entire polygon. Therefore, it'll drop
  1869. >out of use as machines get faster and games get more complex.
  1870.  
  1871. It depends on how you define "not work". You still only draw each pixel
  1872. once with this method, if you do decide to do texture maps.
  1873.  
  1874. You are right about the polygon counts though, but on the PPC scan
  1875. conversion runs very quickly in the cache, since the algorithm uses
  1876. relatively little memory.  This may give new life to the method for a
  1877. while, especially since it allows you to avoid unnecessary screen and
  1878. texture memory access and texture calculations.
  1879.  
  1880. Eventually, it will be replaced by something else, but there's still
  1881. life left in it.
  1882.  
  1883. -- 
  1884. Juri Munkki jmunkki@iki.fi      In cyberspace everyone can hear you scream.
  1885. http://www.iki.fi/~jmunkki              Windsurfing: Faster than the wind.
  1886.  
  1887. +++++++++++++++++++++++++++
  1888.  
  1889. >From phixus@deltanet.com (Chris De Salvo)
  1890. Date: Tue, 28 Nov 1995 08:44:40 -0800
  1891. Organization: MacPlay
  1892.  
  1893. In article <ericd-2411951427110001@slip18.nilenet.com>,
  1894. ericd@ra.nilenet.com (Eric A. Drumbor) wrote:
  1895.  
  1896. >     I've noticed that some of the more popular games (Hornet for
  1897. >instance) are using a delta copy mode.  That is, the only pixels that are
  1898. >copied to the screen are the pixels that have changed color from what is
  1899. >on the screen.
  1900. >
  1901. >     Does this really help?  I suppose it must to some degree, but it
  1902. >seems like an awful lot of checking to see what has changed in the
  1903. >offscreen pixmap.  After all the checking has taken place, and only the
  1904. >changed (delta) pixels have been copied, it doesn't seem like there would
  1905. >be much of a speed gain given the amount of checking (memory accesses, and
  1906. >compares) that take place.
  1907.  
  1908. Normally what you do is divide the screen into sections.  Maybe 32x32
  1909. blocks or something.  Whenever you draw something on the screen you figure
  1910. out which of those bocks are overlapped by the new graphics and you mark
  1911. those blocks at dirty.  Then, when it's time to update the screen you just
  1912. check your dirty-rectangle map and only update those blocks.
  1913.  
  1914. Doing a pixel-for-pixel compare would be MUCH too painful.
  1915.  
  1916. L8R
  1917. Chris
  1918.  
  1919. -- 
  1920. phixus@deltanet.com         |   Macintosh:  Changing the world,
  1921. Chris De Salvo              |        one person at a time!
  1922. Professional Mac Geek       |    -----------------------------
  1923. for MacPlay, Inc.           |      (I wish they'd hurry up!)
  1924.  
  1925.            http://www.deltanet.com/users/phixus
  1926.  
  1927. +++++++++++++++++++++++++++
  1928.  
  1929. >From ajbarry@ozemail.com.au (Andrew Barry)
  1930. Date: Sat, 02 Dec 1995 11:37:08 +1000
  1931. Organization: OzEmail Pty Ltd - Australia
  1932.  
  1933. >      I've noticed that some of the more popular games (Hornet for
  1934. > instance) are using a delta copy mode.  That is, the only pixels that are
  1935. > copied to the screen are the pixels that have changed color from what is
  1936. > on the screen.
  1937. >      Does this really help?  I suppose it must to some degree, but it
  1938. > seems like an awful lot of checking to see what has changed in the
  1939. > offscreen pixmap.  After all the checking has taken place, and only the
  1940. > changed (delta) pixels have been copied, it doesn't seem like there would
  1941. > be much of a speed gain given the amount of checking (memory accesses, and
  1942. > compares) that take place.
  1943. >      Maybe I have the wrong idea on how to go about this, but it doesn't
  1944. > seem worthwhile.  Does anyone have an opinion on the subject?  Please, by
  1945. > all means, prove me wrong... ;-)
  1946.  
  1947. It depends - while your universe is comprised of large flat-shaded
  1948. polygons,then it's worth it.
  1949. If you want to take the next step, and start having fairly detailed
  1950. worlds, then delta copying becomes inefficient.
  1951.  
  1952. ie Becoming dependant on delta-copying can restrict the level of detail in
  1953. your game.
  1954.  
  1955. If you don't mind losing the bottom end of the market, you can get far
  1956. more impressive screens with delta-copying.
  1957.  
  1958. Andrew Barry
  1959.  
  1960. +++++++++++++++++++++++++++
  1961.  
  1962. >From jinjur@kudonet.com (john calhoun)
  1963. Date: 3 Dec 1995 06:17:27 GMT
  1964. Organization: Scheherazade Software
  1965.  
  1966. > In article <ericd-2411951427110001@slip18.nilenet.com>,
  1967. > ericd@ra.nilenet.com (Eric A. Drumbor) wrote:
  1968. > >      I've noticed that some of the more popular games (Hornet for
  1969. > > instance) are using a delta copy mode.  That is, the only pixels that are
  1970. > > copied to the screen are the pixels that have changed color from what is
  1971. > > on the screen.
  1972. > > 
  1973. > >      Does this really help?  I suppose it must to some degree, but it
  1974.  
  1975. It's a phenomenal speed improvement (we got 100% or more of an increase
  1976. when I was helping with the original ZOA).
  1977.  
  1978. That said though, for simulator-type games, it's quickly becoming a relic
  1979. (perhaps to be lodged away with character-graphics).  No offense to A-10
  1980. and such, but when you move away from flat-shaded polygons and go to rich
  1981. texture-mapping, "delta copying" is of no speed benefit (in fact it will
  1982. slow you down).  So, if flat-shaded polygons is where you're headed,
  1983. invest6igate this, but if you're going toward texture-mapping, forget it.
  1984.  
  1985. john calhoun-
  1986.  
  1987. +++++++++++++++++++++++++++
  1988.  
  1989. >From jinjur@kudonet.com (john calhoun)
  1990. Date: 6 Dec 1995 04:12:32 GMT
  1991. Organization: Scheherazade Software
  1992.  
  1993. In article <49505n$nuh@dns.crocker.com>, albtrssp@crocker.com (Kevin
  1994. Tieskoetter) wrote:
  1995. > In article <ericd-2411951427110001@slip18.nilenet.com>
  1996. > ericd@ra.nilenet.com (Eric A. Drumbor) writes:
  1997. > That's where the algorithm is really complicated. I believe they don't
  1998. > actually check which pixels have changed, but rather do it on a
  1999. > polygon-oriented level. I believe that it'll always end up copying by
  2000. > triangles, but I could be wrong.
  2001.  
  2002. Yes and no and sort of.  Yes, you're right, they don't check every pixel,
  2003. but no they don't do it at the polygon level per se.  (And it's sort of
  2004. complicated.)
  2005.  
  2006. They do it at the scanline level (so, sort of the sub-polygon level). 
  2007. It's done by maintaining a run-length encoded (RLE) array for each
  2008. scanline on the screen.  It's a good deal quicker to traverse a RLE array
  2009. to determine what's changed than every pixel.
  2010.  
  2011. BTW, if you ever cheated (hacked) Hellcats so that you could get 100's of
  2012. rockets, it was possible to launch such a volley of rockets that the
  2013. resulting explosions (and their myriad of little polygons) caused the RLE
  2014. scheme to come down to it's knees (and I believe we even crashed the game
  2015. a few times).
  2016.  
  2017. john calhoun-
  2018.  
  2019. +++++++++++++++++++++++++++
  2020.  
  2021. >From dwareing@adelaide.on.net (David Wareing)
  2022. Date: Thu, 14 Dec 1995 17:57:00 +0930
  2023. Organization: Weyland Yutani
  2024.  
  2025. In article <jinjur-0512952010200001@165.227.52.137>, jinjur@kudonet.com
  2026. (john calhoun) wrote:
  2027.  
  2028. >BTW, if you ever cheated (hacked) Hellcats so that you could get 100's of
  2029. >rockets, it was possible to launch such a volley of rockets that the
  2030. >resulting explosions (and their myriad of little polygons) caused the RLE
  2031. >scheme to come down to it's knees (and I believe we even crashed the game
  2032. >a few times).
  2033.  
  2034. I suspect the crash may have been a result of running out of memory,
  2035. thanks to all the extra rockets, rather than a problem with the 
  2036. rendering scheme. When I pumped up Hellcat's memory allocation, the
  2037. crashes did not occur, and everything seemed to be getting drawn ok,
  2038. even with scads of rockets and explosions all over the place. Of
  2039. course, it was as slow as molasses though.
  2040.  
  2041. [your kilometerage may vary]
  2042.  
  2043. -- 
  2044. David Wareing                                 dwareing@adelaide.on.net
  2045. Belair, South Australia           http://www.AmbrosiaSW.com/~dwareing/
  2046. Macintosh Games & Multimedia Programming
  2047.  
  2048.  
  2049. ---------------------------
  2050.  
  2051. >From Dustin_Mitchell@onf.com (Dustin J. Mitchell)
  2052. Subject: NBP Lookups
  2053. Date: 19 Dec 1995 18:37:08 GMT
  2054. Organization: Internet Maine Inc.
  2055.  
  2056. Can anyone explain just how the real-time background lookups are
  2057. accomplished by stuff like Chooser and most games?? When another user
  2058. comes onto the network, the code picks up the new entity pretty quickly
  2059. and throws it on the list. How is this done?
  2060.  
  2061. Also, is it still considered acceptable to use DDP routines for speedy
  2062. communication (i.e. video game)
  2063.  
  2064. Please reply in email--I'll post results here.
  2065.  
  2066. Thanx..
  2067. DustyM
  2068.  
  2069. +++++++++++++++++++++++++++
  2070.  
  2071. >From jumplong@aol.com (Jump Long)
  2072. Date: 22 Dec 1995 02:39:27 -0500
  2073. Organization: America Online, Inc. (1-800-827-6364)
  2074.  
  2075. Dustin J. Mitchell wrote:
  2076.  
  2077. >Can anyone explain just how the real-time background lookups are
  2078. >accomplished by stuff like Chooser and most games?? When another
  2079. >user comes onto the network, the code picks up the new entity
  2080. >pretty quickly and throws it on the list. How is this done?
  2081.  
  2082. They do it by calling PLookupName asynchronously and then look at the
  2083. NBPnumGotten field to catch new matches as they are returned. Here's a
  2084. short example that shows how it's done.
  2085.  
  2086. - Jim Luther
  2087.  
  2088. - ---
  2089.  
  2090. #include  <Memory.h>
  2091. #include  <AppleTalk.h>
  2092. #include  <StdIO.h>
  2093. #include  <Files.h>
  2094.  
  2095. enum
  2096. {
  2097.   kTupleSize     = 104,   /* sizeof(AddrBlock) + a one-byte enumerator + 
  2098.                              sizeof(EntityName) */
  2099.   kStartMatches  = 20,    /* Approximate number of matches to get to
  2100.                              start with */
  2101.   kInterval      = 0x0f,  /* Reasonable starting place for interval... */
  2102.   kCount         = 0x03   /* ...and count */
  2103. };
  2104.  
  2105. void main(void)
  2106. {
  2107.   OSErr         result;
  2108.   MPPParamBlock mppPB;
  2109.   short         lookupAttempt;
  2110.   Ptr           returnBufferPtr;
  2111.   EntityName    lookupEntity, matchEntity;
  2112.   Str32         entityObject = "\p=";         /* find any object */
  2113.   Str32         entityType   = "\pAFPServer"; /* find AppleShare servers
  2114. */
  2115.   Str32         entityZone   = "\p*";         /* in the current zone */
  2116.   short         entityCount  = kStartMatches; /* The maximum number of
  2117. matches
  2118.                                                  we'd like */
  2119.   short         interval     = kInterval;
  2120.   short         count        = kCount;
  2121.   short         currentCount, oldCount;
  2122.   Boolean       done;
  2123.   short         index;
  2124.   AddrBlock     entityAddress;
  2125.   
  2126.   for (lookupAttempt = 1; lookupAttempt <= 5; ++lookupAttempt)
  2127.   {
  2128.     printf("Start Lookup #%d\n",lookupAttempt);
  2129.     
  2130.     /* Allocate buffer for replies */
  2131.     returnBufferPtr = NewPtr((Size) entityCount * (Size) kTupleSize);
  2132.     if ( returnBufferPtr != NULL )
  2133.     {
  2134.       /* Create a packed entity name */
  2135.       NBPSetEntity((Ptr) &lookupEntity, entityObject, entityType,
  2136. entityZone);
  2137.       
  2138.       oldCount = 0;
  2139.           
  2140.       /* ioRefNum and csCode are filled in by PLookupName's glue */
  2141.       mppPB.MPPioCompletion = nil;              /* polling for completion
  2142. */
  2143.       mppPB.NBPinterval = interval;             /* Reasonable values for
  2144.                                                    the interval */
  2145.       mppPB.NBPcount = count;                   /* and retry count */
  2146.       mppPB.NBPentityPtr = (Ptr) &lookupEntity; /* The entity name to
  2147.                                                    look for */
  2148.       mppPB.NBPretBuffPtr = returnBufferPtr;    /* Where the reply tuples
  2149.                                                    will go */
  2150.       mppPB.NBPretBuffSize = (entityCount) * (Size) kTupleSize;
  2151.                                                 /* Return buffer size */
  2152.       mppPB.NBPmaxToGet = entityCount;          /* The number of entities
  2153. the
  2154.                                                    return buffer can hold
  2155. */
  2156.     
  2157.       result = PLookupName(&mppPB, true);       /* Lookup the entity name
  2158.                                                    asynchronously */
  2159.       
  2160.       if ( result == noErr ) /* the request was delivered to the driver */
  2161.       {
  2162.         done = false;
  2163.         do
  2164.         {
  2165.           /* Extract the matches as they come in and
  2166.              add them to the match list */
  2167.           
  2168.           done = (mppPB.MPPioResult <= noErr);  /* is this the last time
  2169.                                                    through? */
  2170.           
  2171.           if ( mppPB.NBPnumGotten > oldCount )  /* anything new to
  2172. display? */
  2173.           {
  2174.             /* yes, so display them */
  2175.             currentCount = mppPB.NBPnumGotten;
  2176.             
  2177.             for ( index = (oldCount + 1); index <= currentCount; ++index)
  2178.             {
  2179.               if ( NBPExtract(returnBufferPtr, currentCount, index,
  2180.                               &matchEntity, &entityAddress) == noErr )
  2181.               {
  2182.                 printf("%08lx %#s:%#s@%#s\n", entityAddress,
  2183.                        matchEntity.objStr, matchEntity.typeStr,
  2184.                        matchEntity.zoneStr);
  2185.               }
  2186.             }
  2187.             oldCount = currentCount;
  2188.           }
  2189.         } while ( !done );
  2190.       }
  2191.       
  2192.       if ( entityCount <=  mppPB.NBPnumGotten )
  2193.         entityCount += 20;  /* get more next time */
  2194.       
  2195.       DisposPtr(returnBufferPtr);  /* Give space back */
  2196.     }
  2197.     
  2198.     printf("Finish Lookup #%d\n",lookupAttempt);
  2199.   }
  2200. }
  2201.  
  2202. - ---
  2203.  
  2204. ---------------------------
  2205.  
  2206. >From Dwight Kelly <dkelly@etsinc.com>
  2207. Subject: PICT opcode $9a?
  2208. Date: Wed, 20 Dec 1995 12:29:31 -0500
  2209. Organization: Essential Technical Services, Inc.
  2210.  
  2211. Does anyone have information on opcode $9a in a PICT2 resource?
  2212.  
  2213. Inside Macintosh volume 5 lists it as a reserved opcode, however,
  2214. most applications including photoshop store their 16 and 32 bit
  2215. PICT previews using $9a.
  2216.  
  2217. -- 
  2218. Dwight Kelly
  2219. Essential Technical Services, Inc.  
  2220. 110 Industrial Park Drive Suite A-2 Cumming, GA 30130
  2221. voice:(770) 889-2848  fax:(770) 889-2624 Internet:dkelly@etsinc.com
  2222. http://www.etsinc.com
  2223.  
  2224. +++++++++++++++++++++++++++
  2225.  
  2226. >From devon@apple.com (Devon Hubbard)
  2227. Date: Wed, 20 Dec 1995 17:18:57 -0800
  2228. Organization: Apple Computer
  2229.  
  2230. In article <30D847FB.27E9C277@etsinc.com>, Dwight Kelly
  2231. <dkelly@etsinc.com> wrote:
  2232.  
  2233. > Does anyone have information on opcode $9a in a PICT2 resource?
  2234. > Inside Macintosh volume 5 lists it as a reserved opcode, however,
  2235. > most applications including photoshop store their 16 and 32 bit
  2236. > PICT previews using $9a.
  2237.  
  2238. OpCode 0x9A is 'Direct CopyBits Rectangle'  It differs slightly from
  2239. OpCode 0x90 (CopyBits Rectangle) in that 0x9A can specify more details
  2240. like pixel size, type, horiz/vertical resolutions, and bit packing.  IM5
  2241. is pretty useless these days huh?  I tried to find reference to it in
  2242. 'Imaging with Quickdraw' with no luck either.  Bummer.
  2243.  
  2244. The actual data, if you're trying to pull it apart in existing pictures is
  2245. easily viewable with Resorcerer's PICT built-in editor.  He (Doug) has
  2246. kept pretty up to date on things like that.  If you don't have Resorcerer,
  2247. it looks like now's a good time to get it.  :-)
  2248.  
  2249. dEVoN
  2250.  
  2251. +++++++++++++++++++++++++++
  2252.  
  2253. >From Dwight Kelly <dkelly@etsinc.com>
  2254. Date: Thu, 21 Dec 1995 11:24:17 -0500
  2255. Organization: MindSpring Enterprises
  2256.  
  2257. On Wed, 20 Dec 1995, Devon Hubbard wrote:
  2258.  
  2259. > > Does anyone have information on opcode $9a in a PICT2 resource?
  2260. > > 
  2261. > OpCode 0x9A is 'Direct CopyBits Rectangle'  It differs slightly from
  2262. > OpCode 0x90 (CopyBits Rectangle) in that 0x9A can specify more details
  2263. > like pixel size, type, horiz/vertical resolutions, and bit packing.  IM5
  2264. > is pretty useless these days huh?  I tried to find reference to it in
  2265. > 'Imaging with Quickdraw' with no luck either.  Bummer.
  2266.  
  2267. I finally found a description in 'Imaging with Quickdraw' in Appendix A on
  2268. pages A-14 and A-15.
  2269.  
  2270. - -
  2271. Dwight Kelly
  2272. Essential Technical Services, Inc.  
  2273. 110 Industrial Park Drive Suite A-2 Cumming, GA 30130
  2274. voice:(770) 889-2848  fax:(770) 889-2624 Internet:dkelly@etsinc.com
  2275. http://www.etsinc.com
  2276.  
  2277.  
  2278.  
  2279.  
  2280. ---------------------------
  2281.  
  2282. >From rik@astro.psu.edu (Ron Kollgaard)
  2283. Subject: Parameter Block woes
  2284. Date: 13 Dec 1995 15:03:16 GMT
  2285. Organization: Dept. of Astronomy and Astrophysics, The Pennsylvania State University
  2286.  
  2287. Okay, this is almost certainly a fit of cluelessness on my part but I'm
  2288. having trouble using some of the File Manager calls, even something simple
  2289. like PBGetVol()  I can pass a ParamBlkPtr to PBGetVol(), but it doesn't
  2290. seem to work right since I can't initialize the ioCompletion pointer in
  2291. the ParamBlkPtr structure.  CW complains that ioCompletion isn't a
  2292. member of the data structure.  I *can* get File Manager routines that use
  2293. CInforPBRec to work (using things like cpbPtr->hFileInfo.ioCompletion = NIL )
  2294. but it doesn't seem to work for a ParamBlkPtr.  
  2295.  
  2296. I'm either missing something really simple here, or it has something to do
  2297. with the ParamBlockRec being defined as a union in the header files?
  2298.  
  2299. Anyway, how does one initilize the ioCompletion bit of a ParamBlkPtr?
  2300.  
  2301. thanks!
  2302. Ron
  2303. rik@astro.psu.edu
  2304.  
  2305.  
  2306. +++++++++++++++++++++++++++
  2307.  
  2308. >From cameron_esfahani@powertalk.apple.com (Cameron Esfahani)
  2309. Date: Wed, 13 Dec 1995 12:53:21 -0800
  2310. Organization: Apple Computer, Inc.
  2311.  
  2312. The trick to understanding how HFS parameter blocks work, is to realize
  2313. that all of the similar fields in all of the parameter blocks are at the
  2314. same offset.  So, to use your example of PBGetVol(), allocate a
  2315. VolumeParam block on the stack:
  2316.    VolumeParam          volPB;
  2317.    OSErr                theErr;
  2318.  
  2319.    volPB.ioCompletion = nil;
  2320.  
  2321.    theErr = PBGetVol((ParmBlkPtr) &volPB);
  2322.  
  2323. Hope this helps,
  2324. Cameron Esfahani
  2325.  
  2326.  
  2327. ---------------------------
  2328.  
  2329. >From cshehadi@panix.com (Charles Shehadi)
  2330. Subject: Pixel manipulation
  2331. Date: Sun, 17 Dec 1995 16:42:54 -0400
  2332. Organization: PANIX Public Access Internet and Unix, NYC
  2333.  
  2334. Hello..
  2335.  
  2336. I'm writing a simple image processing application.  I'd like be able to do
  2337. some calculations on my image pixel by pixel.  My first try at doing this
  2338. is:
  2339.  
  2340. 1. with nested for loops 
  2341. 2. calling GetCPixel(h, v, &temp), then 
  2342. 3. doing the calculations on the red, green, and blue componenents of
  2343. temp, and 4. calling SetCPixel(h,v,&temp).
  2344.  
  2345.  
  2346. This works but it's really slow.  Is there a faster way?  Should I bypass
  2347. using GetCPixel and SetCPixel and deal with the Window's PixMap directly? 
  2348. How would iterate through the image?
  2349.  
  2350.  
  2351. Any ideas would help...
  2352.  
  2353. -Charlie
  2354.  
  2355. +++++++++++++++++++++++++++
  2356.  
  2357. >From ckt@best.com (Chris Thomas)
  2358. Date: Sun, 17 Dec 1995 20:46:12 -0800
  2359. Organization: Echo Software
  2360.  
  2361. In article <cshehadi-1712951642540001@cshehadi.dialup.access.net>,
  2362. cshehadi@panix.com (Charles Shehadi) wrote:
  2363.  
  2364. > Hello..
  2365. > I'm writing a simple image processing application.  I'd like be able to do
  2366. > some calculations on my image pixel by pixel.  My first try at doing this
  2367. > is:
  2368. > 1. with nested for loops 
  2369. > 2. calling GetCPixel(h, v, &temp), then 
  2370. > 3. doing the calculations on the red, green, and blue componenents of
  2371. > temp, and 4. calling SetCPixel(h,v,&temp).
  2372. > This works but it's really slow.  Is there a faster way?  Should I bypass
  2373. > using GetCPixel and SetCPixel and deal with the Window's PixMap directly?
  2374.  
  2375. Yes.
  2376.  
  2377. > How would iterate through the image?
  2378.  
  2379. Put the image in a GWorld and do something like:
  2380. (scuse my psuedocode)
  2381.  
  2382. LockPixels(gWorld)
  2383.  
  2384. for(gWorld->portPixMap.rowBytes/ the height of gWorld->portPixMap)
  2385.     for(gWorld->portPixMap.rowBytes) 
  2386.        MyDoSomethingWithPixel(
  2387.          gWorld->portPixMap->baseAddr[currentRowByte * currentHeight]);
  2388. }
  2389.  
  2390. UnlockPixels(gWorld)
  2391. BlitToMyWindow(gWorld)
  2392.  
  2393. Check out the relevant docs for PixMap and GWorld in MPTA, somewhere
  2394. at http://dev.info.apple.com.  The exact format of a pixel varies
  2395. according to the current screen depth- if you can guarantee that
  2396. you're using a direct color (>=16 bit depth) device, portPixMap->baseAddr
  2397. points to an array of RGBColor.
  2398.  
  2399. And don't forget that portPixMap->baseAddr is a handle when using
  2400. GWorlds.
  2401.  
  2402. -- 
  2403. Chris Thomas, ckt@best.com
  2404.  
  2405. +++++++++++++++++++++++++++
  2406.  
  2407. >From erichsen@pacificnet.net (Erichsen)
  2408. Date: 18 Dec 1995 09:59:35 GMT
  2409. Organization: Disorganized
  2410.  
  2411. In article <cshehadi-1712951642540001@cshehadi.dialup.access.net>,
  2412. cshehadi@panix.com (Charles Shehadi) wrote:
  2413.  
  2414. >This works but it's really slow.  Is there a faster way?  Should I bypass
  2415. >using GetCPixel and SetCPixel and deal with the Window's PixMap directly? 
  2416. >How would iterate through the image?
  2417.  
  2418. Get the Develop Article Drawing in GWorlds for Speed and Versatility. It
  2419. goes thru the process of making a custom routine to get and set a pixel
  2420. that's 624X faster than QuickDraw. It has a lot of other good stuff too.
  2421.  
  2422. +++++++++++++++++++++++++++
  2423.  
  2424. >From s868672@umslvma.umsl.edu (Tracy Findley)
  2425. Date: Mon, 18 Dec 1995 16:32:34 -0600
  2426. Organization: University of Missouri - St. Louis
  2427.  
  2428. In article <cshehadi-1712951642540001@cshehadi.dialup.access.net>,
  2429. cshehadi@panix.com (Charles Shehadi) wrote:
  2430.  
  2431. >Hello..
  2432. >
  2433. >I'm writing a simple image processing application.  I'd like be able to do
  2434. >some calculations on my image pixel by pixel.  My first try at doing this
  2435. >is:
  2436. >
  2437. >1. with nested for loops 
  2438. >2. calling GetCPixel(h, v, &temp), then 
  2439. >3. doing the calculations on the red, green, and blue componenents of
  2440. >temp, and 4. calling SetCPixel(h,v,&temp).
  2441. >
  2442. >
  2443. >This works but it's really slow.  Is there a faster way?  Should I bypass
  2444. >using GetCPixel and SetCPixel and deal with the Window's PixMap directly? 
  2445. >How would iterate through the image?
  2446. >
  2447. >
  2448. >Any ideas would help...
  2449. >
  2450. >-Charlie
  2451.  
  2452. Hi!
  2453.  
  2454. develop - Issue 10 has an article "Drawing in GWorlds for Speed and
  2455. Versatility" that describes in disgusting detail how to properly avoid
  2456. GetCPixel and SetCPixel for fantastic speed boosts.  In their example they
  2457. took a high level routine that took 10.4 seconds to run and whittled it
  2458. down 1/60th of a second; and they stopped there because they didn't want
  2459. to get into assembly!
  2460.  
  2461. I tried to find the URL (I know it's on Apple's web site somewhere) but
  2462. they busy, just look around under "Developer Services."
  2463.  
  2464. Hope this helps,
  2465. David Findley
  2466. s868672@umslvma.umsl.edu
  2467.  
  2468. Tracy Findley
  2469. s868672@umslvma.umsl.edu
  2470.  
  2471. +++++++++++++++++++++++++++
  2472.  
  2473. >From Binky the Wonderwhorse <binky@mmcorp.com>
  2474. Date: 19 Dec 1995 01:45:11 GMT
  2475. Organization: MultiMedia Corporation
  2476.  
  2477. lo,
  2478.  
  2479. >>2. calling GetCPixel(h, v, &temp),
  2480.  
  2481. Aaargh, SLOOOW!
  2482.  
  2483. >>calling SetCPixel(h,v,&temp).
  2484.  
  2485. Same again...Aaargh, SLOOOW!
  2486.  
  2487. >>Is there a faster way?
  2488.  
  2489. Yup (read on)
  2490.  
  2491. >>disgusting detail
  2492.  
  2493. but excellent nonetheless
  2494.  
  2495. >>they didn't want to get into assembly!
  2496.  
  2497. they did use assembly...check out routine FastGWSet32Pixel at the bottom
  2498. of page 66 in may 1992s copy of develop.  Strangely enough, its 680x0
  2499. assembly...I think they meant rewriting all other other routines in
  2500. assembly (the FastSetPixel and FastGetPixel were in assembly I believe).
  2501.  
  2502. >>LockPixels(gWorld)
  2503. >>for(gWorld->portPixMap.rowBytes/ the height of gWorld->portPixMap)
  2504. >>    for(gWorld->portPixMap.rowBytes) 
  2505. >>      MyDoSomethingWithPixel(
  2506. >>        gWorld->portPixMap->baseAddr[currentRowByte * currentHeight]);
  2507. >>}
  2508. >>UnlockPixels(gWorld)
  2509. >>BlitToMyWindow(gWorld)
  2510.  
  2511. err....wheres your refs to rowBytes? (which is rather important and
  2512. easily missed)
  2513.  
  2514. Sheesh, if you want something done properly then ya gotta do it yerself.
  2515. Look, heres a *simple* routine for mirroring an image (horiz flip
  2516. effect).  It will flip a GWorld in 8, 16 or 32 bit. (sorry, I only work
  2517. in colour)
  2518. It shows VERY VERY SIMPLY how to directly access pixels in a bitmap.
  2519. Just copy and paste this into your app code...get a picture, draw it into
  2520. a gworld, call the mirror routine and then blit your gworld onto the
  2521. screen.
  2522. The routine is pretty fast but could easily be enhanced. (use longs for
  2523. pixel transfers on 8 and 16 bit for 4 and 2 times the speed for
  2524. instance...code it in assembly...etc etc)
  2525.  
  2526. Hope this makes things a little more clear for you.
  2527.  
  2528. Binky
  2529.  
  2530. ps. any problems/questions then email me
  2531. pps. i think the 0x3FFF should be 0x7FFF...offhand I forget (so sorry)
  2532.  
  2533. mail: binky@mmcorp.com
  2534. www: http://www.mmcorp.com/~binky
  2535.  
  2536. //
  2537. - ---------------------------------------------------------------------
  2538. - ----------
  2539. //              • MirrorGWorld
  2540. //
  2541. - ---------------------------------------------------------------------
  2542. - ----------
  2543. // Mirror horizontal code that calls the appropriate mirror code
  2544. depending upon bit depth
  2545.  
  2546. void
  2547. MirrorGWorld(GWorldPtr  &sourceGWorld)
  2548. {
  2549.         PixMapHandle    sourcePixMap = NULL;
  2550.         char                    mode = true32b;
  2551.         long                    sourceBase, sourceRowBytes, xMax, yMax;
  2552.         GWorldPtr               destGWorld = NULL;
  2553.         
  2554.         sourcePixMap = GetGWorldPixMap(sourceGWorld);
  2555.         LockPixels(sourcePixMap);
  2556.         
  2557.         sourceBase = (long) GetPixBaseAddr(sourcePixMap) ;
  2558.         sourceRowBytes = (**sourcePixMap).rowBytes &  0x3FFF; /* ignore garbage
  2559. top 2 bits */
  2560.                                 
  2561.         yMax = sourceGWorld->portRect.bottom;
  2562.         xMax = sourceGWorld->portRect.right;
  2563.         
  2564.         SwapMMUMode(&mode);
  2565.         
  2566.         switch( (**sourcePixMap).pixelSize )
  2567.                 {
  2568.                 case 8:
  2569.                         Mirror8Bit(sourceBase, sourceRowBytes, xMax, yMax);
  2570.                         break;
  2571.                 case 16:
  2572.                         Mirror16Bit(sourceBase, sourceRowBytes, xMax, yMax);
  2573.                         break;
  2574.                 case 32:
  2575.                         Mirror32Bit(sourceBase, sourceRowBytes, xMax, yMax);
  2576.                         break;
  2577.                 default:
  2578.                         break;
  2579.                 }
  2580.                 
  2581.         SwapMMUMode(&mode);
  2582.         UnlockPixels(sourcePixMap);
  2583. }
  2584.  
  2585. //
  2586. - ---------------------------------------------------------------------
  2587. - ----------
  2588. //              • Mirror8Bit
  2589. //
  2590. - ---------------------------------------------------------------------
  2591. - ----------
  2592. // mirror an 8 bit image horizontally
  2593. void
  2594. Mirror8Bit(long sourceBase, long sourceRowBytes, long xMax, long yMax)
  2595. {
  2596.         register        char            columnSplit, rowLoop, columnLoop;
  2597.         register        char            *leftPixel, *rightPixel, tempPixel;
  2598.         
  2599.         columnSplit = (xMax >> 1);              // xMax >> 1  =  Trunc(xMax / 2)
  2600.         for (rowLoop = 0; rowLoop < yMax; rowLoop++)    
  2601.                 {
  2602.                 leftPixel = (char*)(sourceBase + (rowLoop*sourceRowBytes));
  2603.                 rightPixel = (char*)(leftPixel + xMax -1);
  2604.                 for (columnLoop = columnSplit; columnLoop; columnLoop--)        
  2605.                         {
  2606.                         tempPixel = *leftPixel;
  2607.                         *leftPixel++ = *rightPixel;
  2608.                         *rightPixel-- = tempPixel;
  2609.                         }
  2610.                 }
  2611. }
  2612. //
  2613. - ---------------------------------------------------------------------
  2614. - ----------
  2615. //              • Mirror16Bit
  2616. //
  2617. - ---------------------------------------------------------------------
  2618. - ----------
  2619. // mirror a 16 bit image horizontally
  2620.  
  2621. void
  2622. Mirror16Bit(long sourceBase, long sourceRowBytes, long xMax, long yMax)
  2623. {
  2624.         register        short           columnSplit, rowLoop, columnLoop;
  2625.         register        short           *leftPixel, *rightPixel, tempPixel;
  2626.         
  2627.         columnSplit = (xMax >> 1);              // xMax >> 1  =  Trunc(xMax / 2)
  2628.         for (rowLoop = 0; rowLoop < yMax; rowLoop++)    
  2629.                 {
  2630.                 leftPixel = (short*)(sourceBase + (rowLoop*sourceRowBytes));
  2631.                 rightPixel = (short*)(leftPixel + xMax -1);
  2632.                 for (columnLoop = columnSplit; columnLoop; columnLoop--)        
  2633.                         {
  2634.                         tempPixel = *leftPixel;
  2635.                         *leftPixel++ = *rightPixel;
  2636.                         *rightPixel-- = tempPixel;
  2637.                         }
  2638.                 }
  2639. }
  2640.  
  2641. //
  2642. - ---------------------------------------------------------------------
  2643. - ----------
  2644. //              • Mirror32Bit
  2645. //
  2646. - ---------------------------------------------------------------------
  2647. - ----------
  2648. // mirror a 32 bit image horizontally
  2649. void
  2650. Mirror32Bit(long sourceBase, long sourceRowBytes, long xMax, long yMax)
  2651. {
  2652.         register        long            columnSplit, rowLoop, columnLoop;
  2653.         register        long            *leftPixel, *rightPixel, tempPixel;
  2654.         
  2655.         columnSplit = (xMax >> 1);              // xMax >> 1  =  Trunc(xMax / 2)
  2656.         for (rowLoop = 0; rowLoop < yMax; rowLoop++)    
  2657.                 {
  2658.                 leftPixel = (long*)(sourceBase + (rowLoop*sourceRowBytes));
  2659.                 rightPixel = (long*)(leftPixel + xMax -1);
  2660.                 for (columnLoop = columnSplit; columnLoop; columnLoop--)        
  2661.                         {
  2662.                         tempPixel = *leftPixel;
  2663.                         *leftPixel++ = *rightPixel;
  2664.                         *rightPixel-- = tempPixel;
  2665.                         }
  2666.                 }
  2667. }
  2668.  
  2669. ---------------------------
  2670.  
  2671. >From arnold@lumina.com (Brian Arnold)
  2672. Subject: Stupid locked file question
  2673. Date: Tue, 19 Dec 1995 13:54:04 -0800
  2674. Organization: Lumina Decision Systems, Inc.
  2675.  
  2676. Okay, this is a really stupid question, but I've never supported
  2677. Finder-locked files before.
  2678.  
  2679. The Finder Get Info window has a "Locked" checkbox for files.  What do I
  2680. call to check that this checkbox is checked for a file I am opening?
  2681.  
  2682. I looked at FSpGetFInfo, which returns a name locked bit, but it doesn't
  2683. get set by the "Locked" checkbox.  I then scanned the Files book of New
  2684. Inside Mac, and a lot of functions are capable of returning this error:
  2685.  
  2686.    fLckdErr -45    File is locked
  2687.  
  2688. But my file calls never return this for files that have the "Locked" checkbox.  
  2689.  
  2690. So what routine do I call, and what bit do I test, to find out whether a
  2691. file has been locked in the Get Info window?
  2692.  
  2693. - Brian
  2694.  
  2695. -- 
  2696. Brian Arnold
  2697. Director of Software Development
  2698. Lumina Decision Systems, Inc.
  2699. http://www.lumina.com/lumina/
  2700.  
  2701. +++++++++++++++++++++++++++
  2702.  
  2703. >From howlett@netcom.com (Scott Howlett)
  2704. Date: Wed, 20 Dec 1995 01:49:31 GMT
  2705. Organization: (or lack thereof)
  2706.  
  2707. Brian Arnold wrote:
  2708.  
  2709. > Okay, this is a really stupid question, but I've never supported
  2710. > Finder-locked files before.
  2711. ...
  2712. > So what routine do I call, and what bit do I test, to find out whether a
  2713. > file has been locked in the Get Info window?
  2714.  
  2715. To lock a file, use FSpSetFLock.
  2716. To unlock a file, use FSpRstFLock.
  2717. To test a file lock, use this:
  2718.  
  2719. OSErr
  2720. FSpTestFLock(FSSpec *pSpec, Boolean *pIsLocked)
  2721. {
  2722.     CInfoPBRec pb;
  2723.     OSErr err;
  2724.  
  2725.     pb.hFileInfo.ioNamePtr = pSpec->name;
  2726.     pb.hFileInfo.ioVRefNum = pSpec->vRefNum;
  2727.     pb.hFileInfo.ioDirID = pSpec->parID;
  2728.     pb.hFileInfo.ioFDirIndex = 0;
  2729.     
  2730.     if ((err = PBGetCatInfo(&pb, FALSE)) == noErr)
  2731.         *pIsLocked = pb.hFileInfo.ioFlAttrib & 1;
  2732.  
  2733.     return err;
  2734. }
  2735.  
  2736. - Scott
  2737.  
  2738. -- 
  2739. Scott Howlett, howlett@netcom.com
  2740. "Probably the earliest fly swatters were nothing more than some sort of 
  2741. striking surface attached to the end of a long stick."
  2742.  
  2743. +++++++++++++++++++++++++++
  2744.  
  2745. >From phixus@deltanet.com (Chris De Salvo)
  2746. Date: Tue, 19 Dec 1995 21:44:20 -0800
  2747. Organization: MacPlay
  2748.  
  2749. In article <arnold-1912951354040001@227.rahul.net>, arnold@lumina.com
  2750. (Brian Arnold) wrote:
  2751.  
  2752. >So what routine do I call, and what bit do I test, to find out whether a
  2753. >file has been locked in the Get Info window?
  2754.  
  2755. Personally, I'd use PBGetCatInfo() on the file.  Then, look at the
  2756. ioFlAttrib field of the hFileInfo structure.  Bit zero tells you whether
  2757. or not the file is locked.
  2758.  
  2759. L8R
  2760. Chris.
  2761.  
  2762. -- 
  2763. phixus@deltanet.com         |   Macintosh:  Changing the world,
  2764. Chris De Salvo              |        one person at a time!
  2765. Professional Mac Geek       |    -----------------------------
  2766. for MacPlay, Inc.           |      (I wish they'd hurry up!)
  2767.  
  2768.            http://www.deltanet.com/users/phixus
  2769.  
  2770. +++++++++++++++++++++++++++
  2771.  
  2772. >From erichsen@pacificnet.net (Erichsen)
  2773. Date: 21 Dec 1995 10:27:48 GMT
  2774. Organization: Disorganized
  2775.  
  2776. In article <arnold-1912951354040001@227.rahul.net>, arnold@lumina.com
  2777. (Brian Arnold) wrote:
  2778.  
  2779. >The Finder Get Info window has a "Locked" checkbox for files.  What do I
  2780. >call to check that this checkbox is checked for a file I am opening?
  2781.  
  2782. Call PBGetCatInfo and check the ioFlAttrib to see if the locked bit is set
  2783. (ie. pb.hFileInfo.ioFlAttrib & 0x01 ) != 0) . Also check out MoreFiles,
  2784. it's a set of routines written by one of Apple's DTS guys (Jim Luther but,
  2785. I think he's at General Magic now). It has a routine in the
  2786. MoreFilesExtras.c file called CheckObjectLock/FSpCheckObjectLock that does
  2787. exactly what you're asking. Here's the code from MoreFiles:
  2788.  
  2789. /*****************************************************************************/
  2790.  
  2791. pascal  OSErr   FSpCheckObjectLock(const FSSpec *spec)
  2792. {
  2793.     return ( CheckObjectLock(spec->vRefNum, spec->parID,
  2794. (StringPtr)spec->name) );
  2795.  
  2796. /*****************************************************************************/
  2797.  
  2798. pascal  OSErr   CheckObjectLock(short vRefNum,
  2799.                                 long dirID,
  2800.                                 StringPtr name)
  2801. {
  2802.     CInfoPBRec pb;
  2803.     Str31 tempName;
  2804.     OSErr error;
  2805.     
  2806.     /* Protection against File Sharing problem */
  2807.     if ( (name == NULL) || (name[0] == 0) )
  2808.     {
  2809.         tempName[0] = 0;
  2810.         pb.hFileInfo.ioNamePtr = tempName;
  2811.         pb.hFileInfo.ioFDirIndex = -1;  /* use ioDirID */
  2812.     }
  2813.     else
  2814.     {
  2815.         pb.hFileInfo.ioNamePtr = name;
  2816.         pb.hFileInfo.ioFDirIndex = 0;   /* use ioNamePtr and ioDirID */
  2817.     }
  2818.     pb.hFileInfo.ioVRefNum = vRefNum;
  2819.     pb.hFileInfo.ioDirID = dirID;
  2820.     error = PBGetCatInfoSync(&pb);
  2821.     
  2822.     if ( error == noErr )
  2823.     {
  2824.         /* check locked bit */
  2825.         if ( (pb.hFileInfo.ioFlAttrib & 0x01) != 0 )
  2826.             error = fLckdErr;
  2827.     }
  2828.     return ( error );
  2829. }
  2830.  
  2831. ---------------------------
  2832.  
  2833. >From masc1175@rohan.sdsu.edu (Generic Account 1175)
  2834. Subject: Using Enqueue() and Dequeue() for custom-made queues
  2835. Date: 14 Dec 95 16:33:19 GMT
  2836. Organization: San Diego State University
  2837.  
  2838. I've been attempting to use the MacOS EnQueue() and Dequeue() functions
  2839. to store items, instead of creating my own queue structure.  The IM
  2840. OS Queues chapter doesn't say enough about doing this, and the only
  2841. example I've been able to find in a book (the "Reminder" program in the
  2842. C Mac Programming Primer book) isn't very helpful.
  2843.  
  2844. Basically, what I've got is this:
  2845.  
  2846. typedef struct
  2847. {
  2848.         short stuff;
  2849.         short moreStuff;
  2850.         short junk;
  2851. } StuffRecord;
  2852.  
  2853. QHdr stuffQueue;
  2854.  
  2855. (later)
  2856.  
  2857. void EnqueueMyStuff(short x, short y, short z)
  2858. {
  2859.         StuffRecord *myStuff = (StuffRecord *)NewPtr(sizeof(StuffRecord));
  2860.         myStuff->stuff = x;
  2861.         myStuff->moreStuff = y;
  2862.         myStuff->junk = z;
  2863.         Enqueue((QElemPtr)myStuff,&stuffQueue);
  2864. }
  2865.  
  2866. This is in imitation of the very brief code snippet in the OS Queues
  2867. chapter.  It doesn't work--when I get stuff off the queue, the data is
  2868. inevitably worthless garbage.
  2869.  
  2870. The Primer has a slightly different method, wherein the "StuffRecord"
  2871. would have a new field, queue of type QElem.  The Enqueue() statement
  2872. would then read:  Enqueue(&myStuff->queue,&stuffQueue).  This doesn't
  2873. seem to work either.
  2874.  
  2875. What am I doing wrong?
  2876. (Oh--I'm using CW 7 on a Performa 638.  Not that that is much help, I
  2877. suppose.)
  2878.  
  2879. -et 
  2880. -- 
  2881. Ernest S. Tomlinson (masc1175@rohan.sdsu.edu) (et@ugcs.caltech.edu)
  2882. - -----------------------------------------------------------------
  2883. "LOOK UPON ME!  I'LL SHOW YOU THE LIFE OF THE MIND!  I WILL SHOW
  2884. YOU THE LIFE OF THE MIND!!"
  2885.  
  2886. +++++++++++++++++++++++++++
  2887.  
  2888. >From Matt Slot <fprefect@umich.edu>
  2889. Date: 15 Dec 1995 04:40:36 GMT
  2890. Organization: University of Michigan
  2891.  
  2892. Generic Account 1175, masc1175@rohan.sdsu.edu writes:
  2893.  > typedef struct
  2894.  > {
  2895.  >      short stuff;
  2896.  >      short moreStuff;
  2897.  >      short junk;
  2898.  > } StuffRecord;
  2899.  > 
  2900.  > [...]
  2901.  >
  2902.  > This is in imitation of the very brief code snippet in the OS Queues
  2903.  > chapter.  It doesn't work--when I get stuff off the queue, the data is
  2904.  > inevitably worthless garbage.
  2905.  > 
  2906.  > The Primer has a slightly different method, wherein the "StuffRecord"
  2907.  > would have a new field, queue of type QElem.  The Enqueue() statement
  2908.  > would then read:  Enqueue(&myStuff->queue,&stuffQueue).  This doesn't
  2909.  > seem to work either.
  2910.  
  2911.  
  2912. Your struct should be declared like this:
  2913.  
  2914.         typedef struct
  2915.         {
  2916.          QElem *qElem;
  2917.          short qType;
  2918.         
  2919.          // Your Data Here
  2920.          short stuff;
  2921.          short moreStuff;
  2922.          short junk;
  2923.         } StuffRecord;
  2924.  
  2925. The Enqueue() and DeQueue() calls expect the first 6 bytes to be
  2926. available for management (actually, the qType is only *really* 
  2927. important for OS-maintained queues).
  2928.  
  2929.  
  2930.  
  2931. * * * * * * * * * * * * * * * * * * * * * * * * * * ======================
  2932. *  Reality: Matt Slot                             *  Time is an illusion.
  2933. *  E-Mail:  mailto:fprefect@umich.edu             *  Lunchtime doubly so.
  2934. *  Web:     http://www.sils.umich.edu/~fprefect/  *     -- Douglas Adams
  2935. * * * * * * * * * * * * * * * * * * * * * * * * * * ======================
  2936.  
  2937. +++++++++++++++++++++++++++
  2938.  
  2939. >From erichsen@pacificnet.net (Erichsen)
  2940. Date: 15 Dec 1995 17:47:27 GMT
  2941. Organization: Disorganized
  2942.  
  2943. In article <masc1175.818958799@rohan>, masc1175@rohan.sdsu.edu (Generic
  2944. Account 1175) wrote:
  2945.  
  2946. >I've been attempting to use the MacOS EnQueue() and Dequeue() functions
  2947. >to store items, instead of creating my own queue structure.  The IM
  2948. >OS Queues chapter doesn't say enough about doing this, and the only
  2949. >example I've been able to find in a book (the "Reminder" program in the
  2950. >C Mac Programming Primer book) isn't very helpful.
  2951. >
  2952. >Basically, what I've got is this:
  2953. >
  2954. >typedef struct
  2955. >{
  2956. >        short stuff;
  2957. >        short moreStuff;
  2958. >        short junk;
  2959. >} StuffRecord;
  2960.  
  2961. The problem is you aren't giving Enqueue a field to store it's link. The
  2962. qLink field is important. Enqueue uses it to keep track of the elements in
  2963. the queue.
  2964.  
  2965. You need to setup your structure like this:
  2966.  
  2967. struct  ElementRecord
  2968. {
  2969.     struct  ElementRecord   *qLink;
  2970.     short                   qType;
  2971.  
  2972.     // Add Your Stuff After the First qLink and qType.
  2973.  
  2974.     short                   stuff;
  2975.     short                   moreStuff;
  2976.     short                   junk;
  2977.  
  2978.     // Any other stuff you need.
  2979. };
  2980.  
  2981. typedef struct  ElementRecord   ElementRecord, 
  2982.                                 *ElementPtr;
  2983.  
  2984.  
  2985. Then you add an element to your custom queue like this:
  2986.  
  2987. ...
  2988.   
  2989.     OSErr           error;
  2990.     ElementPtr      element;
  2991.  
  2992.     element = ( ElementPtr ) NewPtrClear( sizeof( ElementRecord ) );
  2993.     error = MemError();
  2994.     if( error != noErr ) return( error );
  2995.  
  2996.     element->stuff      = -1;
  2997.     element->moreStuff  = 0;
  2998.     element->junk       = 1;
  2999.  
  3000.     Enqueue( ( QElemPtr ) element, &gYourCustomQueue );
  3001.  
  3002. ...
  3003.  
  3004. ---------------------------
  3005.  
  3006. >From David Reiss <reiss@astro.washington.edu>
  3007. Subject: [HELP] New to color palettes...simple question!
  3008. Date: 1 Dec 1995 21:25:05 GMT
  3009. Organization: http://www.astro.washington.edu
  3010.  
  3011. Hi.  I am trying to create a window which uses a custom palette which
  3012. I have created as a resource with 256 slightly different shades of
  3013. blue.  Here's the simple code after I create the window (hidden, for
  3014. the moment)...
  3015.  
  3016. PaletteHandle myPalette = GetNewPalette( 1000 );
  3017. SetPalette( myWindow, myPalette, TRUE );
  3018.  
  3019. Simple enough...but now when my window gets shown on an 8 bit Mac, the
  3020. expected shifting of color tables so that everything looks blue does not
  3021. occur...in fact, I can draw greens, reds, etc. onto my window.  Am I 
  3022. missing a call, to build an inverse color table, or something? I'd
  3023. appreciate any theories.  Thanks.
  3024.  
  3025. -David
  3026.  
  3027.  
  3028. +++++++++++++++++++++++++++
  3029.  
  3030. >From heaney@crl.com (John S. Heaney)
  3031. Date: 1 Dec 1995 22:06:22 -0800
  3032. Organization: CRL Dialup Internet Access        (415) 705-6060  [Login: guest]
  3033.  
  3034. In article <49nrrh$h5j@nntp5.u.washington.edu>,
  3035. David Reiss  <reiss@astro.washington.edu> wrote:
  3036.  
  3037. >Simple enough...but now when my window gets shown on an 8 bit Mac, the
  3038. >expected shifting of color tables so that everything looks blue does not
  3039. >occur...in fact, I can draw greens, reds, etc. onto my window.  Am I 
  3040. >missing a call, to build an inverse color table, or something? I'd
  3041. >appreciate any theories.  Thanks.
  3042.  
  3043. Try an ActivatePalette( myWindow );
  3044.  
  3045. -- 
  3046. John Heaney              Time flies whether you're having fun or not.
  3047. heaney@crl.com
  3048.  
  3049. +++++++++++++++++++++++++++
  3050.  
  3051. >From adamnash@cs.stanford.edu (Adam Nash)
  3052. Date: Tue, 05 Dec 1995 04:58:17 -0800
  3053. Organization: Computer Science, Stanford University
  3054.  
  3055. In article <49oqcu$o1j@crl5.crl.com>, heaney@crl.com (John S. Heaney) wrote:
  3056.  
  3057. > >Simple enough...but now when my window gets shown on an 8 bit Mac, the
  3058. > >expected shifting of color tables so that everything looks blue does not
  3059. > >occur...in fact, I can draw greens, reds, etc. onto my window.  Am I 
  3060. > >missing a call, to build an inverse color table, or something? I'd
  3061. > >appreciate any theories.  Thanks.
  3062. > Try an ActivatePalette( myWindow );
  3063.  
  3064. ActivatePalette is crucial, but you still may run into problems if your
  3065. colors are set to tolerant.  To be safe, set their tolerance to 0.  Note,
  3066. this is
  3067. really bad style, since the Mac Toolbox *insists* that your first two colors
  3068. should be white and black.  So try that w/ 254 blues, no tolerance, and
  3069. ActivatePalette.  Also, Try checking the Advanced Imaging Inside
  3070. Macintosh, available on Apple's ftp site.
  3071.  
  3072.    -Adam
  3073.  
  3074. -- 
  3075. Adam Nash
  3076. CS 108 TA
  3077. adamnash@cs.stanford.edu
  3078. http://www-leland.stanford.edu/~smashman
  3079. Stanford University - Computer Science
  3080.  
  3081. +++++++++++++++++++++++++++
  3082.  
  3083. >From jstiles@cello.gina.calstate.edu (John Stiles)
  3084. Date: Fri, 15 Dec 1995 06:34:32 GMT
  3085. Organization: cello.gina.calstate.edu
  3086.  
  3087. In article <adamnash-0512950458170001@gel.stanford.edu>,
  3088. adamnash@cs.stanford.edu (Adam Nash) wrote:
  3089.  
  3090. >ActivatePalette is crucial, but you still may run into problems if your
  3091. >colors are set to tolerant.  To be safe, set their tolerance to 0.  Note,
  3092.  
  3093.  I just tackled palettes a few days ago, and another important step is:
  3094.  
  3095.  SelectWindow( myWindow );
  3096.  
  3097.  Don't laugh. If you're messing around with 10 windows, each with its own
  3098. palette, this instruction determines which palette gets used. So it really
  3099. IS important. :) Although when I first put it in, and my code worked, I
  3100. was scratching my head as to why... :)
  3101.  
  3102.  *Stiles
  3103.  
  3104. +++++++++++++++++++++++++++
  3105.  
  3106. >From David Reiss <reiss@astro.washington.edu>
  3107. Date: 18 Dec 1995 23:31:46 GMT
  3108. Organization: http://www.astro.washington.edu
  3109.  
  3110. Yes, I discovered this as well, and now I got it to work...except when I'm
  3111. using my floating windows environment, in which case SelectWindow()
  3112. never gets called.  Do you, or anyone else, know of a way around this
  3113. problem?  (It seems when you solve one problem, another one springs up
  3114. as a result.)
  3115.  
  3116. Thanks.
  3117.  
  3118. -David
  3119.  
  3120. ---------------------------
  3121.  
  3122. End of C.S.M.P. Digest
  3123. **********************
  3124.